Skip to content

Spatial SQL Queries

Ammar Bakeer edited this page Aug 30, 2016 · 1 revision

Creating Table with Grid Index

Create external table table_name ([shape_col_name(s)] [shape_type], [col(s)]) partitioned by (tag string) row format delimited fields terminated by [','|'\t'|...] location '[hdfs_location]' tblproperties ('globalIndex'='[hdfs_global_master_file_location]', 'index'='shape_col_name(s) ');

Creating Table with RTree Index

Create external table table_name ([shape_col_name(s)] [shape_type], [col(s)]) partitioned by (tag string) row format delimited fields terminated by [','|'\t'|...] stored as rtree location '[hdfs_location]' tblproperties ('globalIndex'='[hdfs_global_master_file_location]', 'index'='shap e_col_name(s)');

Range Query

Select [column name(s) | * ] from table_name where inside([shape_column_name(s)_separated_by_comma(s)], Rectangle(x_1,y_1,x_2,y_2)) [And|Or] expression;

Join Query

Select [column name(s) | * ] from [table_name_1], [table_name_2] where overlaps([shape_1], [shape_2]) [And|Or] expression;

Clone this wiki locally