Repository: phoenix Updated Branches: refs/heads/calcite 75caf0906 -> 3fd7d965d
PHOENIX-3347 Set conformance level to PhoenixSqlConformance Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3fd7d965 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3fd7d965 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3fd7d965 Branch: refs/heads/calcite Commit: 3fd7d965dc306389d8d1402f47c6faeb45f8ae03 Parents: 75caf09 Author: maryannxue <[email protected]> Authored: Tue Nov 8 14:14:23 2016 -0800 Committer: maryannxue <[email protected]> Committed: Tue Nov 8 14:14:23 2016 -0800 ---------------------------------------------------------------------- .../calcite/jdbc/PhoenixCalciteFactory.java | 175 +++++++++++++++++++ .../phoenix/calcite/PhoenixSqlConformance.java | 58 ++++++ .../jdbc/PhoenixCalciteEmbeddedDriver.java | 5 - 3 files changed, 233 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/3fd7d965/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java b/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java index faab40a..b0040e9 100644 --- a/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java +++ b/phoenix-core/src/main/java/org/apache/calcite/jdbc/PhoenixCalciteFactory.java @@ -1,5 +1,6 @@ package org.apache.calcite.jdbc; +import java.io.File; import java.io.InputStream; import java.io.Reader; import java.sql.NClob; @@ -28,7 +29,14 @@ import org.apache.calcite.avatica.AvaticaStatement; import org.apache.calcite.avatica.Meta; import org.apache.calcite.avatica.Meta.Signature; import org.apache.calcite.avatica.Meta.StatementHandle; +import org.apache.calcite.avatica.remote.AvaticaHttpClientFactory; +import org.apache.calcite.avatica.remote.Service.Factory; import org.apache.calcite.avatica.remote.TypedValue; +import org.apache.calcite.avatica.util.Casing; +import org.apache.calcite.avatica.util.Quoting; +import org.apache.calcite.config.CalciteConnectionConfig; +import org.apache.calcite.config.Lex; +import org.apache.calcite.config.NullCollation; import org.apache.calcite.avatica.QueryState; import org.apache.calcite.avatica.UnregisteredDriver; import org.apache.calcite.jdbc.CalciteConnectionImpl; @@ -36,9 +44,12 @@ import org.apache.calcite.jdbc.CalciteFactory; import org.apache.calcite.jdbc.Driver; import org.apache.calcite.linq4j.Enumerable; import org.apache.calcite.linq4j.Ord; +import org.apache.calcite.model.JsonSchema.Type; import org.apache.calcite.schema.SchemaPlus; +import org.apache.calcite.sql.validate.SqlConformance; import org.apache.phoenix.calcite.CalciteUtils; import org.apache.phoenix.calcite.PhoenixSchema; +import org.apache.phoenix.calcite.PhoenixSqlConformance; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.exception.SQLExceptionInfo; import org.apache.phoenix.execute.RuntimeContext; @@ -121,6 +132,17 @@ public class PhoenixCalciteFactory extends CalciteFactory { } @Override + public CalciteConnectionConfig config() { + final CalciteConnectionConfig config = super.config(); + return new DelegateCalciteConnectionConfig(config) { + @Override + public SqlConformance conformance() { + return PhoenixSqlConformance.INSTANCE; + } + }; + } + + @Override public CalciteStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { try { return super.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); @@ -470,4 +492,157 @@ public class PhoenixCalciteFactory extends CalciteFactory { super(connection); } } + + private static class DelegateCalciteConnectionConfig implements CalciteConnectionConfig { + private final CalciteConnectionConfig delegate; + + DelegateCalciteConnectionConfig(CalciteConnectionConfig delegate) { + this.delegate = delegate; + } + + @Override + public String authentication() { + return delegate.authentication(); + } + + @Override + public String avaticaPassword() { + return delegate.avaticaPassword(); + } + + @Override + public String avaticaUser() { + return delegate.avaticaUser(); + } + + @Override + public Factory factory() { + return delegate.factory(); + } + + @Override + public String httpClientClass() { + return delegate.httpClientClass(); + } + + @Override + public AvaticaHttpClientFactory httpClientFactory() { + return delegate.httpClientFactory(); + } + + @Override + public File kerberosKeytab() { + return delegate.kerberosKeytab(); + } + + @Override + public String kerberosPrincipal() { + return delegate.kerberosPrincipal(); + } + + @Override + public String schema() { + return delegate.schema(); + } + + @Override + public String serialization() { + return delegate.serialization(); + } + + @Override + public String timeZone() { + return delegate.timeZone(); + } + + @Override + public String url() { + return delegate.url(); + } + + @Override + public boolean autoTemp() { + return delegate.autoTemp(); + } + + @Override + public boolean materializationsEnabled() { + return delegate.materializationsEnabled(); + } + + @Override + public boolean createMaterializations() { + return delegate.createMaterializations(); + } + + @Override + public NullCollation defaultNullCollation() { + return delegate.defaultNullCollation(); + } + + @Override + public <T> T fun(Class<T> operatorTableClass, T defaultOperatorTable) { + return delegate.fun(operatorTableClass, defaultOperatorTable); + } + + @Override + public String model() { + return delegate.model(); + } + + @Override + public Lex lex() { + return delegate.lex(); + } + + @Override + public Quoting quoting() { + return delegate.quoting(); + } + + @Override + public Casing unquotedCasing() { + return delegate.unquotedCasing(); + } + + @Override + public Casing quotedCasing() { + return delegate.quotedCasing(); + } + + @Override + public boolean caseSensitive() { + return delegate.caseSensitive(); + } + + @Override + public <T> T schemaFactory(Class<T> schemaFactoryClass, T defaultSchemaFactory) { + return delegate.schemaFactory(schemaFactoryClass, defaultSchemaFactory); + } + + @Override + public Type schemaType() { + return delegate.schemaType(); + } + + @Override + public boolean spark() { + return delegate.spark(); + } + + @Override + public boolean forceDecorrelate() { + return delegate.forceDecorrelate(); + } + + @Override + public <T> T typeSystem(Class<T> typeSystemClass, T defaultTypeSystem) { + return delegate.typeSystem(typeSystemClass, defaultTypeSystem); + } + + @Override + public SqlConformance conformance() { + return delegate.conformance(); + } + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/3fd7d965/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSqlConformance.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSqlConformance.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSqlConformance.java new file mode 100644 index 0000000..0e35867 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixSqlConformance.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.calcite; + +import org.apache.calcite.sql.validate.SqlConformance; + +public class PhoenixSqlConformance implements SqlConformance { + + public static final PhoenixSqlConformance INSTANCE = + new PhoenixSqlConformance(); + + private PhoenixSqlConformance() { } + + @Override + public boolean isSortByOrdinal() { + return true; + } + + @Override + public boolean isSortByAlias() { + return true; + } + + @Override + public boolean isSortByAliasObscures() { + return false; + } + + @Override + public boolean isFromRequired() { + return false; + } + + @Override + public boolean isBangEqualAllowed() { + return true; + } + + @Override + public boolean isMinusAllowed() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/3fd7d965/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixCalciteEmbeddedDriver.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixCalciteEmbeddedDriver.java b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixCalciteEmbeddedDriver.java index b20bcfc..36088ba 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixCalciteEmbeddedDriver.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/jdbc/PhoenixCalciteEmbeddedDriver.java @@ -31,7 +31,6 @@ import org.apache.calcite.jdbc.CalcitePrepare; import org.apache.calcite.jdbc.Driver; import org.apache.calcite.linq4j.function.Function0; import org.apache.calcite.schema.SchemaPlus; -import org.apache.calcite.sql.validate.SqlConformance; import org.apache.phoenix.calcite.PhoenixPrepareImpl; import org.apache.phoenix.calcite.PhoenixSchema; import org.apache.phoenix.calcite.rules.PhoenixConverterRules; @@ -92,10 +91,6 @@ public abstract class PhoenixCalciteEmbeddedDriver extends Driver implements SQL PhoenixRelDataTypeSystem.class.getName()); setPropertyIfNotSpecified( info2, - CalciteConnectionProperty.CONFORMANCE.camelName(), - SqlConformance.ORACLE_10.toString()); - setPropertyIfNotSpecified( - info2, CalciteConnectionProperty.MATERIALIZATIONS_ENABLED.camelName(), Boolean.TRUE.toString());
