Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CALCITE-6239] Add a postgis dialect that supports ST functions #3668

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
edd6adb
[CALCITE-6239] Add a postgis dialect that supports ST functions
bchapuis Jan 17, 2024
7f3a1a2
Fix the registration of the geometry schema
bchapuis Feb 3, 2024
84abbce
Place postgis before postgres whenever it makes sense
bchapuis Feb 3, 2024
c515d58
Add support for implicit type conversion from binary to geometry
bchapuis Feb 5, 2024
d37cbb6
Add a geometry parser to bind jdbc geometries to calcite geometries
bchapuis Feb 6, 2024
1a297e7
Improve naming and fix minor issues
bchapuis Feb 7, 2024
3b37b54
Use lenient conformance
bchapuis Feb 8, 2024
2607023
Remove blank line
bchapuis Feb 13, 2024
ef5a48e
Ignore casing when checking the type name
bchapuis Feb 13, 2024
a9caca8
Add a built in method to decode postgis geometries
bchapuis Feb 13, 2024
65dab8a
Remove unnecessary comment
bchapuis Feb 13, 2024
a855375
Use reflection to register the geometry type family
bchapuis Feb 13, 2024
671d316
Consistently use PostGIS instead of Posgis
bchapuis Feb 13, 2024
93568cd
Remove unnecessary functions from SqlKind
bchapuis Feb 13, 2024
fc31956
Document the extension of the PostgreSQL dialect by the PostGIS dialect
bchapuis Feb 13, 2024
151bbe5
Use SqlKind instead of Strings in the PostGIS dialect
bchapuis Feb 13, 2024
67b97f3
Fix the error message of the unit test for the OTHER type
bchapuis Feb 13, 2024
3b05b97
Format the code with autostyle
bchapuis Feb 13, 2024
90fe0b6
Fix style and coding issues
bchapuis Feb 13, 2024
e826ab5
Fix the javadoc
bchapuis Feb 13, 2024
5be15b3
Move the PostgisGeometryDecoder into the util package
bchapuis Feb 13, 2024
94d49fe
Add test cases for the postgis geometry decoder
bchapuis Feb 13, 2024
5fb31b8
Remove reference to removed ST functions
bchapuis Feb 13, 2024
76ae1e6
Format the code
bchapuis Feb 13, 2024
5096e84
Revert changes in the sql dialect
bchapuis Feb 13, 2024
488df2e
Check null value in the postgis geometry decoder
bchapuis Feb 14, 2024
5432471
Add a lexical policy for PostgreSQL
bchapuis Feb 14, 2024
40d4418
Add nullable annotation to geometry decoder
bchapuis Feb 14, 2024
75893e7
Improve casting of decoded geometries
bchapuis Feb 14, 2024
cf66678
Add annotation Parameter.sqlType
julianhyde Mar 5, 2024
3634120
More
julianhyde Mar 7, 2024
ef38d08
Adapt more functions to the geometry type parameter
bchapuis Mar 7, 2024
05985b4
Remove the JTS type
bchapuis Mar 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix the registration of the geometry schema
  • Loading branch information
bchapuis committed Feb 8, 2024
commit 7f3a1a2bf540c2cee57b126df92aac72519ee199
21 changes: 17 additions & 4 deletions testkit/src/main/java/org/apache/calcite/test/CalciteAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,25 @@
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rel.type.RelDataTypeImpl;
import org.apache.calcite.rel.type.RelProtoDataType;
import org.apache.calcite.runtime.*;
import org.apache.calcite.runtime.AccumOperation;
import org.apache.calcite.runtime.CalciteException;
import org.apache.calcite.runtime.CollectOperation;
import org.apache.calcite.runtime.Hook;
import org.apache.calcite.runtime.SpatialTypeFunctions;
import org.apache.calcite.runtime.UnionOperation;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.schema.SchemaPlus;
import org.apache.calcite.schema.SchemaVersion;
import org.apache.calcite.schema.Statistic;
import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.TableFunction;
import org.apache.calcite.schema.Wrapper;
import org.apache.calcite.schema.impl.*;
import org.apache.calcite.schema.impl.AbstractSchema;
import org.apache.calcite.schema.impl.AbstractTable;
import org.apache.calcite.schema.impl.AggregateFunctionImpl;
import org.apache.calcite.schema.impl.TableFunctionImpl;
import org.apache.calcite.schema.impl.ViewTable;
import org.apache.calcite.schema.impl.ViewTableMacro;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlDialect;
import org.apache.calcite.sql.SqlExplainLevel;
Expand Down Expand Up @@ -856,11 +866,14 @@ static SchemaPlus addSchema_(SchemaPlus rootSchema, SchemaSpec schema) {
SpatialTypeFunctions.class.getName(), "*", true);
ModelHandler.addFunctions(rootSchema, null, emptyPath,
SqlSpatialTypeFunctions.class.getName(), "*", true);

rootSchema.add("ST_UNION", AggregateFunctionImpl.create(UnionOperation.class));
rootSchema.add("ST_ACCUM", AggregateFunctionImpl.create(AccumOperation.class));
rootSchema.add("ST_COLLECT", AggregateFunctionImpl.create(CollectOperation.class));

final SchemaPlus s =
rootSchema.add(schema.schemaName, new AbstractSchema());
rootSchema.add(schema.schemaName, new ReflectiveSchema(new GeometrySchema()));

ModelHandler.addFunctions(s, "countries", emptyPath,
CountriesTableFunction.class.getName(), null, false);
final String sql = "select * from table(\"countries\"(true))";
Expand All @@ -886,7 +899,7 @@ static SchemaPlus addSchema_(SchemaPlus rootSchema, SchemaSpec schema) {
ViewTable.viewMacro(rootSchema, sql3,
ImmutableList.of("GEO"), emptyPath, false);
s.add("parks", viewMacro3);
rootSchema.add(schema.schemaName, new ReflectiveSchema(new GeometrySchema()));

return s;
case HR:
return rootSchema.add(schema.schemaName,
Expand Down