Move PG Types to cml-spi (#10)

* move pg types to cml-spi

* fix copyright statements
This commit is contained in:
Jia-Xuan Liu
2022-05-23 17:36:25 +08:00
committed by GitHub
parent 9de9275bd1
commit e5d6cb5a75
82 changed files with 223 additions and 282 deletions
-47
View File
@@ -32,11 +32,6 @@
<artifactId>log</artifactId>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
@@ -63,11 +58,6 @@
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -83,51 +73,14 @@
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>io.cml</groupId>
<artifactId>cml-spi</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${dep.antlr.version}</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -30,7 +30,7 @@ import io.cml.spi.connector.Connector;
import io.cml.spi.metadata.MetadataUtil;
import io.cml.spi.metadata.SchemaTableName;
import io.cml.spi.metadata.TableMetadata;
import io.cml.type.VarcharType;
import io.cml.spi.type.VarcharType;
import javax.inject.Inject;
-5
View File
@@ -54,11 +54,6 @@
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>io.cml</groupId>
<artifactId>cml-main</artifactId>
</dependency>
<dependency>
<groupId>io.cml</groupId>
<artifactId>cml-spi</artifactId>
@@ -32,9 +32,9 @@ import static io.cml.pgcatalog.builder.BigQueryUtils.createOrReplaceAllColumn;
import static io.cml.pgcatalog.builder.BigQueryUtils.createOrReplaceAllTable;
import static io.cml.pgcatalog.builder.BigQueryUtils.getOidToBqType;
import static io.cml.pgcatalog.builder.PgCatalogTableBuilderUtils.generatePgTypeRecords;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.RegprocType.REGPROC;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.RegprocType.REGPROC;
import static io.cml.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
import static java.util.stream.Collectors.joining;
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,7 @@ import java.util.Locale;
import static io.cml.pgcatalog.PgCatalogUtils.PG_CATALOG_NAME;
import static io.cml.pgcatalog.builder.BigQueryUtils.getOidToBqType;
import static io.cml.spi.metadata.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
public class BigQueryPgFunctionBuilder
@@ -16,33 +16,33 @@ package io.cml.pgcatalog.builder;
import com.google.common.collect.ImmutableMap;
import io.cml.spi.connector.Connector;
import io.cml.type.PGArray;
import io.cml.spi.type.PGArray;
import java.util.List;
import java.util.Map;
import static io.cml.pgcatalog.PgCatalogUtils.CML_TEMP_NAME;
import static io.cml.type.BigIntType.BIGINT;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.BpCharType.BPCHAR;
import static io.cml.type.ByteaType.BYTEA;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.DateType.DATE;
import static io.cml.type.DoubleType.DOUBLE;
import static io.cml.type.InetType.INET;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.JsonType.JSON;
import static io.cml.type.NumericType.NUMERIC;
import static io.cml.type.OidType.OID_INSTANCE;
import static io.cml.type.RealType.REAL;
import static io.cml.type.RegprocType.REGPROC;
import static io.cml.type.SmallIntType.SMALLINT;
import static io.cml.type.TimestampType.TIMESTAMP;
import static io.cml.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE;
import static io.cml.type.UuidType.UUID;
import static io.cml.type.VarcharType.NameType.NAME;
import static io.cml.type.VarcharType.TextType.TEXT;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BigIntType.BIGINT;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.BpCharType.BPCHAR;
import static io.cml.spi.type.ByteaType.BYTEA;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.DateType.DATE;
import static io.cml.spi.type.DoubleType.DOUBLE;
import static io.cml.spi.type.InetType.INET;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.JsonType.JSON;
import static io.cml.spi.type.NumericType.NUMERIC;
import static io.cml.spi.type.OidType.OID_INSTANCE;
import static io.cml.spi.type.RealType.REAL;
import static io.cml.spi.type.RegprocType.REGPROC;
import static io.cml.spi.type.SmallIntType.SMALLINT;
import static io.cml.spi.type.TimestampType.TIMESTAMP;
import static io.cml.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE;
import static io.cml.spi.type.UuidType.UUID;
import static io.cml.spi.type.VarcharType.NameType.NAME;
import static io.cml.spi.type.VarcharType.TextType.TEXT;
import static io.cml.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
public final class BigQueryUtils
@@ -17,7 +17,7 @@ package io.cml.pgcatalog.builder;
import com.google.common.collect.Streams;
import io.cml.pgcatalog.OidHash;
import io.cml.pgcatalog.table.PgCatalogTable;
import io.cml.type.PGTypes;
import io.cml.spi.type.PGTypes;
import java.util.List;
import java.util.Map;
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,9 +19,9 @@ import com.google.common.collect.ImmutableList;
import static io.cml.pgcatalog.function.PgFunction.Argument.argument;
import static io.cml.pgcatalog.function.PgFunction.Language.SQL;
import static io.cml.pgcatalog.function.PgFunction.builder;
import static io.cml.type.BigIntType.BIGINT;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BigIntType.BIGINT;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
public final class PgFunctions
{
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -17,7 +17,7 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.VarcharType.VARCHAR;
public class CharacterSets
extends PgCatalogTable
@@ -16,7 +16,7 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.VarcharType.VARCHAR;
public class KeyColumnUsage
extends PgCatalogTable
@@ -16,9 +16,9 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -17,8 +17,8 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -16,11 +16,11 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -15,14 +15,14 @@
package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import io.cml.type.BooleanType;
import io.cml.spi.type.BooleanType;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.DoubleType.DOUBLE;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.DoubleType.DOUBLE;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* @see <a href="https://www.postgresql.org/docs/13/catalog-pg-class.html">PostgreSQL pg_class</a>
@@ -17,11 +17,11 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.INT4_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.INT4_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -16,10 +16,10 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* @see <a href="https://www.postgresql.org/docs/10/catalog-pg-database.html">PostgreSQL pg_database</a>
@@ -17,8 +17,8 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -17,9 +17,9 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.DoubleType.DOUBLE;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.DoubleType.DOUBLE;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -17,10 +17,10 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.INT4_ARRAY;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.INT4_ARRAY;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -17,9 +17,9 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* @see <a href="https://www.postgresql.org/docs/13/catalog-pg-namespace.html">PostgreSQL pg_namespace</a>
@@ -17,15 +17,15 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.DoubleType.DOUBLE;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.CHAR_ARRAY;
import static io.cml.type.PGArray.INT4_ARRAY;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.RegprocType.REGPROC;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.DoubleType.DOUBLE;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.CHAR_ARRAY;
import static io.cml.spi.type.PGArray.INT4_ARRAY;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.RegprocType.REGPROC;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* @see <a href="https://www.postgresql.org/docs/13/catalog-pg-proc.html">PostgreSQL pg_proc</a>
@@ -16,8 +16,8 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -16,11 +16,11 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -15,10 +15,10 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -17,9 +17,9 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.PGArray.VARCHAR_ARRAY;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.PGArray.VARCHAR_ARRAY;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* this table is unused in Cannerflow, so just an empty table
@@ -16,11 +16,11 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.RegprocType.REGPROC;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.RegprocType.REGPROC;
import static io.cml.spi.type.VarcharType.VARCHAR;
/**
* @see <a href="https://www.postgresql.org/docs/8.4/catalog-pg-type.html#CATALOG-TYPCATEGORY-TABLE">PostgreSQL pg_type</a>
@@ -17,7 +17,7 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.VarcharType.VARCHAR;
public class ReferentialConstraints
extends PgCatalogTable
@@ -17,7 +17,7 @@ package io.cml.pgcatalog.table;
import io.cml.spi.metadata.TableMetadata;
import static io.cml.pgcatalog.table.PgCatalogTableUtils.table;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.VarcharType.VARCHAR;
public class TableConstraints
extends PgCatalogTable
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,7 +19,7 @@ import io.airlift.log.Logger;
import io.cml.spi.CmlException;
import io.cml.spi.Column;
import io.cml.spi.type.PGType;
import io.cml.type.PGTypes;
import io.cml.spi.type.PGTypes;
import io.cml.wireprotocol.ssl.SslReqHandler;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -3,7 +3,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
+37
View File
@@ -23,6 +23,11 @@
<artifactId>log</artifactId>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>hppc</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
@@ -34,11 +39,26 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@@ -101,4 +121,21 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${dep.antlr.version}</version>
<executions>
<execution>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,16 +12,13 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
import static com.google.common.base.Preconditions.checkArgument;
import static io.cml.type.PgDatetimeUtils.toPgTimestamp;
import static io.cml.type.PgDatetimeUtils.toTrinoTimestamp;
import static java.lang.String.format;
abstract class BaseTimestampType
@@ -39,7 +36,7 @@ abstract class BaseTimestampType
public int writeAsBinary(ByteBuf buffer, @Nonnull Object value)
{
buffer.writeInt(TYPE_LEN);
buffer.writeLong(toPgTimestamp((long) value));
buffer.writeLong(PgDatetimeUtils.toPgTimestamp((long) value));
return INT32_BYTE_SIZE + TYPE_LEN;
}
@@ -60,6 +57,6 @@ abstract class BaseTimestampType
{
checkArgument(valueLength == TYPE_LEN, format("valueLength must be %s because timestamp is a 64 bit long. Actual length is %s", TYPE_LEN, valueLength));
long microSecondsSince2K = buffer.readLong();
return toTrinoTimestamp(microSecondsSince2K);
return PgDatetimeUtils.toTrinoTimestamp(microSecondsSince2K);
}
}
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,10 +12,9 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import com.google.common.collect.ImmutableSet;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import org.apache.commons.codec.binary.Hex;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import java.util.Map;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import org.joda.time.Period;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;
@@ -12,12 +12,11 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Bytes;
import io.cml.spi.type.PGType;
import io.cml.type.parser.PgArrayParserWrapper;
import io.cml.spi.type.parser.PgArrayParserWrapper;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -25,12 +24,10 @@ import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.DateType.DATE;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.OidType.OID_INSTANCE;
import static io.cml.type.UuidType.UUID;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.DateType.DATE;
import static io.cml.spi.type.IntegerType.INTEGER;
public class PGArray
extends PGType<List<Object>>
@@ -39,7 +36,7 @@ public class PGArray
public static final PGArray BPCHAR_ARRAY = new PGArray(1014, BpCharType.BPCHAR);
public static final PGArray INT2_ARRAY = new PGArray(1005, SmallIntType.SMALLINT);
public static final PGArray INT4_ARRAY = new PGArray(1007, INTEGER);
public static final PGArray OID_ARRAY = new PGArray(1028, OID_INSTANCE);
public static final PGArray OID_ARRAY = new PGArray(1028, OidType.OID_INSTANCE);
public static final PGArray INT8_ARRAY = new PGArray(1016, BigIntType.BIGINT);
public static final PGArray FLOAT4_ARRAY = new PGArray(1021, RealType.REAL);
public static final PGArray FLOAT8_ARRAY = new PGArray(1022, DoubleType.DOUBLE);
@@ -52,7 +49,7 @@ public class PGArray
public static final PGArray TIMESTAMP_WITH_TIMEZONE_ARRAY = new PGArray(1185, TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE);
public static final PGArray TIMESTAMP_ARRAY = new PGArray(1115, TimestampType.TIMESTAMP);
public static final PGArray DATE_ARRAY = new PGArray(1182, DATE);
public static final PGArray UUID_ARRAY = new PGArray(2951, UUID);
public static final PGArray UUID_ARRAY = new PGArray(2951, UuidType.UUID);
public static final PGArray BYTEA_ARRAY = new PGArray(1001, ByteaType.BYTEA);
public static final PGArray INET_ARRAY = new PGArray(1041, InetType.INET);
public static final PGArray EMPTY_RECORD_ARRAY = new PGArray(2287, RecordType.EMPTY_RECORD);
@@ -12,39 +12,27 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import com.google.common.collect.ImmutableMap;
import io.cml.spi.type.PGType;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import static io.cml.type.AnyType.ANY;
import static io.cml.type.BigIntType.BIGINT;
import static io.cml.type.BooleanType.BOOLEAN;
import static io.cml.type.BpCharType.BPCHAR;
import static io.cml.type.ByteaType.BYTEA;
import static io.cml.type.CharType.CHAR;
import static io.cml.type.DateType.DATE;
import static io.cml.type.DoubleType.DOUBLE;
import static io.cml.type.HstoreType.HSTORE;
import static io.cml.type.InetType.INET;
import static io.cml.type.IntegerType.INTEGER;
import static io.cml.type.JsonType.JSON;
import static io.cml.type.NumericType.NUMERIC;
import static io.cml.type.OidType.OID_INSTANCE;
import static io.cml.type.RealType.REAL;
import static io.cml.type.RecordType.EMPTY_RECORD;
import static io.cml.type.SmallIntType.SMALLINT;
import static io.cml.type.TimestampType.TIMESTAMP;
import static io.cml.type.TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE;
import static io.cml.type.UuidType.UUID;
import static io.cml.type.VarcharType.NameType.NAME;
import static io.cml.type.VarcharType.TextType.TEXT;
import static io.cml.type.VarcharType.VARCHAR;
import static io.cml.spi.type.BigIntType.BIGINT;
import static io.cml.spi.type.BooleanType.BOOLEAN;
import static io.cml.spi.type.CharType.CHAR;
import static io.cml.spi.type.DateType.DATE;
import static io.cml.spi.type.HstoreType.HSTORE;
import static io.cml.spi.type.IntegerType.INTEGER;
import static io.cml.spi.type.RealType.REAL;
import static io.cml.spi.type.SmallIntType.SMALLINT;
import static io.cml.spi.type.TimestampType.TIMESTAMP;
import static io.cml.spi.type.VarcharType.NameType.NAME;
import static io.cml.spi.type.VarcharType.TextType.TEXT;
import static io.cml.spi.type.VarcharType.VARCHAR;
import static java.lang.String.format;
public final class PGTypes
@@ -60,26 +48,26 @@ public final class PGTypes
TYPE_TABLE.put(INTEGER.oid(), INTEGER);
TYPE_TABLE.put(BIGINT.oid(), BIGINT);
TYPE_TABLE.put(REAL.oid(), REAL);
TYPE_TABLE.put(DOUBLE.oid(), DOUBLE);
TYPE_TABLE.put(NUMERIC.oid(), NUMERIC);
TYPE_TABLE.put(DoubleType.DOUBLE.oid(), DoubleType.DOUBLE);
TYPE_TABLE.put(NumericType.NUMERIC.oid(), NumericType.NUMERIC);
TYPE_TABLE.put(VARCHAR.oid(), VARCHAR);
TYPE_TABLE.put(CHAR.oid(), CHAR);
TYPE_TABLE.put(JSON.oid(), JSON);
TYPE_TABLE.put(JsonType.JSON.oid(), JsonType.JSON);
TYPE_TABLE.put(TIMESTAMP.oid(), TIMESTAMP);
TYPE_TABLE.put(TIMESTAMP_WITH_TIMEZONE.oid(), TIMESTAMP_WITH_TIMEZONE);
TYPE_TABLE.put(TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE.oid(), TimestampWithTimeZoneType.TIMESTAMP_WITH_TIMEZONE);
TYPE_TABLE.put(TEXT.oid(), TEXT);
TYPE_TABLE.put(NAME.oid(), NAME);
TYPE_TABLE.put(OID_INSTANCE.oid(), OID_INSTANCE);
TYPE_TABLE.put(OidType.OID_INSTANCE.oid(), OidType.OID_INSTANCE);
TYPE_TABLE.put(DATE.oid(), DATE);
TYPE_TABLE.put(BYTEA.oid(), BYTEA);
TYPE_TABLE.put(BPCHAR.oid(), BPCHAR);
TYPE_TABLE.put(ByteaType.BYTEA.oid(), ByteaType.BYTEA);
TYPE_TABLE.put(BpCharType.BPCHAR.oid(), BpCharType.BPCHAR);
// we handle all unspecified type as text type.
TYPE_TABLE.put(0, TEXT);
TYPE_TABLE.put(INET.oid(), INET);
TYPE_TABLE.put(EMPTY_RECORD.oid(), EMPTY_RECORD);
TYPE_TABLE.put(InetType.INET.oid(), InetType.INET);
TYPE_TABLE.put(RecordType.EMPTY_RECORD.oid(), RecordType.EMPTY_RECORD);
// Just need a fake instance to do type mapping. We never use the field.
TYPE_TABLE.put(HSTORE.oid(), HSTORE);
TYPE_TABLE.put(UUID.oid(), UUID);
TYPE_TABLE.put(UuidType.UUID.oid(), UuidType.UUID);
ImmutableMap.Builder<Integer, PGArray> innerToPgTypeBuilder = ImmutableMap.builder();
// initial collection types
@@ -92,7 +80,7 @@ public final class PGTypes
TYPES = new HashSet<>(TYPE_TABLE.values());
// the following polymorphic types are added manually,
// because there are no corresponding data types in Cannerflow
TYPES.add(ANY);
TYPES.add(AnyType.ANY);
}
public static Iterable<PGType<?>> pgTypes()
@@ -12,7 +12,7 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
public final class PgDatetimeUtils
{
@@ -12,10 +12,9 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import com.google.common.base.Joiner;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,17 +12,16 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import com.carrotsearch.hppc.ByteArrayList;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import java.util.List;
import java.util.Map;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.cml.type.PGArray.EMPTY_RECORD_ARRAY;
import static io.cml.spi.type.PGArray.EMPTY_RECORD_ARRAY;
public class RecordType
extends PGType<Map<String, Object>>
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,10 +12,9 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.CmlException;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,9 +12,8 @@
* limitations under the License.
*/
package io.cml.type;
package io.cml.spi.type;
import io.cml.spi.type.PGType;
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
@@ -12,7 +12,7 @@
* limitations under the License.
*/
package io.cml.type.parser;
package io.cml.spi.type.parser;
import com.carrotsearch.hppc.ByteArrayList;
import io.cml.spi.type.parser.antlr.v4.PgArrayBaseVisitor;
@@ -12,7 +12,7 @@
* limitations under the License.
*/
package io.cml.type.parser;
package io.cml.spi.type.parser;
import io.cml.spi.CmlException;
import io.cml.spi.type.parser.antlr.v4.PgArrayLexer;
@@ -12,7 +12,7 @@
* limitations under the License.
*/
package io.cml.type.parser;
package io.cml.spi.type.parser;
import io.cml.spi.CmlException;
import io.cml.spi.type.parser.antlr.v4.PgDateTimeFormatBaseVisitor;
@@ -12,7 +12,7 @@
* limitations under the License.
*/
package io.cml.type.parser;
package io.cml.spi.type.parser;
import io.cml.spi.CmlException;
import io.cml.spi.type.parser.antlr.v4.PgNumericFormatBaseVisitor;
@@ -27,7 +27,6 @@ import org.antlr.v4.runtime.Recognizer;
import org.antlr.v4.runtime.tree.ParseTree;
import static io.cml.spi.metadata.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static java.lang.String.format;
public final class PgNumericFormatParserWrapper
{
@@ -108,7 +107,7 @@ public final class PgNumericFormatParserWrapper
@Override
public String visitNonReservedPattern(PgNumericFormatParser.NonReservedPatternContext ctx)
{
throw new CmlException(GENERIC_INTERNAL_ERROR, format("we didn't support the pattern %s.", ctx.getText()));
throw new CmlException(GENERIC_INTERNAL_ERROR, String.format("we didn't support the pattern %s.", ctx.getText()));
}
}
}