public <T> T fun(Class<T> operatorTableClass, T defaultOperatorTable) { final String fun = CalciteConnectionProperty.FUN.wrap(properties).getString(); if (fun == null || fun.equals("") || fun.equals("standard")) { return defaultOperatorTable; } final Collection<SqlOperatorTable> tables = new LinkedHashSet<>(); for (String s : fun.split(",")) { operatorTable(s, tables); } tables.add(SqlStdOperatorTable.instance()); return operatorTableClass.cast( ChainedSqlOperatorTable.of( tables.toArray(new SqlOperatorTable[0]))); }
public <T> T fun(Class<T> operatorTableClass, T defaultOperatorTable) { final String fun = CalciteConnectionProperty.FUN.wrap(properties).getString(); if (fun == null || fun.equals("") || fun.equals("standard")) { return defaultOperatorTable; } final Collection<SqlOperatorTable> tables = new LinkedHashSet<>(); for (String s : fun.split(",")) { operatorTable(s, tables); } tables.add(SqlStdOperatorTable.instance()); return operatorTableClass.cast( ChainedSqlOperatorTable.of( tables.toArray(new SqlOperatorTable[0]))); }
private SqlValidator createSqlValidator(Context context, CalciteCatalogReader catalogReader) { final SqlOperatorTable opTab0 = context.config().fun(SqlOperatorTable.class, SqlStdOperatorTable.instance()); final SqlOperatorTable opTab = ChainedSqlOperatorTable.of(opTab0, catalogReader); final JavaTypeFactory typeFactory = context.getTypeFactory(); final SqlConformance conformance = context.config().conformance(); return new CalciteSqlValidator(opTab, catalogReader, typeFactory, conformance); }
private SqlValidator createSqlValidator(Context context, CalciteCatalogReader catalogReader) { final SqlOperatorTable opTab0 = context.config().fun(SqlOperatorTable.class, SqlStdOperatorTable.instance()); final SqlOperatorTable opTab = ChainedSqlOperatorTable.of(opTab0, catalogReader); final JavaTypeFactory typeFactory = context.getTypeFactory(); final SqlConformance conformance = context.config().conformance(); return new CalciteSqlValidator(opTab, catalogReader, typeFactory, conformance); }
private SqlValidator createSqlValidator(Context context, CalciteCatalogReader catalogReader) { final SqlOperatorTable opTab0 = context.config().fun(SqlOperatorTable.class, SqlStdOperatorTable.instance()); final SqlOperatorTable opTab = ChainedSqlOperatorTable.of(opTab0, catalogReader); final JavaTypeFactory typeFactory = context.getTypeFactory(); final SqlConformance conformance = context.config().conformance(); return new CalciteSqlValidator(opTab, catalogReader, typeFactory, conformance); }
public FlinkPlannerImpl(FrameworkConfig frameworkConfig) { this.relBuilder = BlinkRelBuilder.create(frameworkConfig); this.planner = relBuilder.getPlanner(); this.typeFactory = relBuilder.getTypeFactory(); this.traitDefs = frameworkConfig.getTraitDefs(); this.parserConfig = frameworkConfig.getParserConfig(); this.convertletTable = frameworkConfig.getConvertletTable(); this.defaultSchema = frameworkConfig.getDefaultSchema(); SqlOperatorTable builtinOperatorTable = frameworkConfig.getOperatorTable(); CalciteCatalogReader catalogReader = this.createCatalogReader(); this.operatorTable = ChainedSqlOperatorTable.of(builtinOperatorTable, catalogReader); this.validator = new FlinkSqlValidator(this.operatorTable, catalogReader, this.typeFactory); this.validator.setIdentifierExpansion(true); }
protected SqlTester oracleTester() { return tester.withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())) .withConnectionFactory( CalciteAssert.EMPTY_CONNECTION_FACTORY .with(new CalciteAssert .AddSchemaSpecPostProcessor(CalciteAssert.SchemaSpec.HR)) .with(CalciteConnectionProperty.FUN, "oracle")); }
protected SqlTester oracleTester() { return tester.withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())) .withConnectionFactory( CalciteAssert.EMPTY_CONNECTION_FACTORY .with(new CalciteAssert .AddSchemaSpecPostProcessor(CalciteAssert.SchemaSpec.HR)) .with(CalciteConnectionProperty.FUN, "oracle")); }
@Test public void testTranslate3() { // TRANSLATE3 is not in the standard operator table checkWholeExpFails("translate('aabbcc', 'ab', '+-')", "No match found for function signature TRANSLATE3\\(<CHARACTER>, <CHARACTER>, <CHARACTER>\\)"); tester = tester.withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())); checkExpType("translate('aabbcc', 'ab', '+-')", "VARCHAR(6) NOT NULL"); checkWholeExpFails("translate('abc', 'ab')", "Invalid number of arguments to function 'TRANSLATE3'. Was expecting 3 arguments"); checkWholeExpFails("translate('abc', 'ab', 123)", "(?s)Cannot apply 'TRANSLATE3' to arguments of type 'TRANSLATE3\\(<CHAR\\(3\\)>, <CHAR\\(2\\)>, <INTEGER>\\)'\\. .*"); checkWholeExpFails("translate('abc', 'ab', '+-', 'four')", "Invalid number of arguments to function 'TRANSLATE3'. Was expecting 3 arguments"); }
protected SqlTester oracleTester(SqlConformance conformance) { if (conformance == null) { conformance = SqlConformanceEnum.DEFAULT; } return tester .withConformance(conformance) .withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())) .withConnectionFactory( CalciteAssert.EMPTY_CONNECTION_FACTORY .with(new CalciteAssert .AddSchemaSpecPostProcessor(CalciteAssert.SchemaSpec.HR)) .with("fun", "oracle") .with("conformance", conformance)); }
protected SqlTester oracleTester(SqlConformance conformance) { if (conformance == null) { conformance = SqlConformanceEnum.DEFAULT; } return tester .withConformance(conformance) .withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())) .withConnectionFactory( CalciteAssert.EMPTY_CONNECTION_FACTORY .with(new CalciteAssert .AddSchemaSpecPostProcessor(CalciteAssert.SchemaSpec.HR)) .with("fun", "oracle") .with("conformance", conformance)); }
@Test public void testTranslate3() { // TRANSLATE3 is not in the standard operator table checkWholeExpFails("translate('aabbcc', 'ab', '+-')", "No match found for function signature TRANSLATE3\\(<CHARACTER>, <CHARACTER>, <CHARACTER>\\)"); tester = tester.withOperatorTable( ChainedSqlOperatorTable.of(OracleSqlOperatorTable.instance(), SqlStdOperatorTable.instance())); checkExpType("translate('aabbcc', 'ab', '+-')", "VARCHAR(6) NOT NULL"); checkWholeExpFails("translate('abc', 'ab')", "Invalid number of arguments to function 'TRANSLATE3'. Was expecting 3 arguments"); checkWholeExpFails("translate('abc', 'ab', 123)", "(?s)Cannot apply 'TRANSLATE3' to arguments of type 'TRANSLATE3\\(<CHAR\\(3\\)>, <CHAR\\(2\\)>, <INTEGER>\\)'\\. .*"); checkWholeExpFails("translate('abc', 'ab', '+-', 'four')", "Invalid number of arguments to function 'TRANSLATE3'. Was expecting 3 arguments"); }
@Test public void testValidateUserDefinedAggregate() throws Exception { final SqlStdOperatorTable stdOpTab = SqlStdOperatorTable.instance(); SqlOperatorTable opTab = ChainedSqlOperatorTable.of(stdOpTab, new ListSqlOperatorTable( ImmutableList.of(new MyCountAggFunction())));
@Test public void testValidateUserDefinedAggregate() throws Exception { final SqlStdOperatorTable stdOpTab = SqlStdOperatorTable.instance(); SqlOperatorTable opTab = ChainedSqlOperatorTable.of(stdOpTab, new ListSqlOperatorTable( ImmutableList.of(new MyCountAggFunction())));