Java Code Examples for org.apache.calcite.sql.validate.SqlNameMatchers#withCaseSensitive()

The following examples show how to use org.apache.calcite.sql.validate.SqlNameMatchers#withCaseSensitive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlinkCalciteCatalogReader.java    From flink with Apache License 2.0 6 votes vote down vote up
public FlinkCalciteCatalogReader(
	CalciteSchema rootSchema,
	List<List<String>> defaultSchemas,
	RelDataTypeFactory typeFactory,
	CalciteConnectionConfig config) {

	super(
		rootSchema,
		SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
			Stream.concat(
				defaultSchemas.stream(),
				Stream.of(Collections.<String>emptyList())
			).collect(Collectors.toList()),
		typeFactory,
		config);
}
 
Example 2
Source File: FlinkCalciteCatalogReader.java    From flink with Apache License 2.0 6 votes vote down vote up
public FlinkCalciteCatalogReader(
	CalciteSchema rootSchema,
	List<List<String>> defaultSchemas,
	RelDataTypeFactory typeFactory,
	CalciteConnectionConfig config) {

	super(
		rootSchema,
		SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
			Stream.concat(
				defaultSchemas.stream(),
				Stream.of(Collections.<String>emptyList())
			).collect(Collectors.toList()),
		typeFactory,
		config);
}
 
Example 3
Source File: CalciteCatalogReader.java    From Bats with Apache License 2.0 5 votes vote down vote up
public CalciteCatalogReader(CalciteSchema rootSchema,
    List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) {
  this(rootSchema, SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
      ImmutableList.of(Objects.requireNonNull(defaultSchema),
          ImmutableList.of()),
      typeFactory, config);
}
 
Example 4
Source File: CatalogReader.java    From flink with Apache License 2.0 5 votes vote down vote up
public CatalogReader(
		CalciteSchema rootSchema,
		List<List<String>> defaultSchema,
		RelDataTypeFactory typeFactory,
		CalciteConnectionConfig config) {
	super(rootSchema,
		SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
		Stream.concat(
			defaultSchema.stream(),
			Stream.of(Collections.<String>emptyList())
		).collect(Collectors.toList()),
		typeFactory,
		config);
}
 
Example 5
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void lookupOperatorOverloads(
		SqlIdentifier opName,
		SqlFunctionCategory category,
		SqlSyntax syntax,
		List<SqlOperator> operatorList,
		SqlNameMatcher nameMatcher) {
	// set caseSensitive=false to make sure the behavior is same with before.
	super.lookupOperatorOverloads(opName, category, syntax, operatorList, SqlNameMatchers.withCaseSensitive(false));
}
 
Example 6
Source File: CatalogReader.java    From flink with Apache License 2.0 5 votes vote down vote up
public CatalogReader(
		CalciteSchema rootSchema,
		List<List<String>> defaultSchema,
		RelDataTypeFactory typeFactory,
		CalciteConnectionConfig config) {
	super(rootSchema,
		SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
		Stream.concat(
			defaultSchema.stream(),
			Stream.of(Collections.<String>emptyList())
		).collect(Collectors.toList()),
		typeFactory,
		config);
}
 
Example 7
Source File: FlinkSqlOperatorTable.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void lookupOperatorOverloads(
		SqlIdentifier opName,
		SqlFunctionCategory category,
		SqlSyntax syntax,
		List<SqlOperator> operatorList,
		SqlNameMatcher nameMatcher) {
	// set caseSensitive=false to make sure the behavior is same with before.
	super.lookupOperatorOverloads(opName, category, syntax, operatorList, SqlNameMatchers.withCaseSensitive(false));
}
 
Example 8
Source File: CalciteCatalogReader.java    From calcite with Apache License 2.0 5 votes vote down vote up
public CalciteCatalogReader(CalciteSchema rootSchema,
    List<String> defaultSchema, RelDataTypeFactory typeFactory, CalciteConnectionConfig config) {
  this(rootSchema, SqlNameMatchers.withCaseSensitive(config != null && config.caseSensitive()),
      ImmutableList.of(Objects.requireNonNull(defaultSchema),
          ImmutableList.of()),
      typeFactory, config);
}
 
Example 9
Source File: MockCatalogReader.java    From calcite with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a MockCatalogReader.
 *
 * <p>Caller must then call {@link #init} to populate with data.</p>
 *
 * @param typeFactory Type factory
 */
public MockCatalogReader(RelDataTypeFactory typeFactory,
    boolean caseSensitive) {
  super(CalciteSchema.createRootSchema(false, false, DEFAULT_CATALOG),
      SqlNameMatchers.withCaseSensitive(caseSensitive),
      ImmutableList.of(PREFIX, ImmutableList.of()),
      typeFactory, null);
}
 
Example 10
Source File: DremioCatalogReader.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public SqlNameMatcher nameMatcher() {
  return SqlNameMatchers.withCaseSensitive(false);
}
 
Example 11
Source File: TestSQLAnalyzer.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
public SqlNameMatcher nameMatcher() {
  return SqlNameMatchers.withCaseSensitive(caseSensitive);
}
 
Example 12
Source File: LookupOperatorOverloadsTest.java    From calcite with Apache License 2.0 4 votes vote down vote up
private void checkInternal(boolean caseSensitive) throws SQLException {
  final SqlNameMatcher nameMatcher =
      SqlNameMatchers.withCaseSensitive(caseSensitive);
  final String schemaName = "MySchema";
  final String funcName = "MyFUNC";
  final String anotherName = "AnotherFunc";

  try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
    CalciteConnection calciteConnection =
        connection.unwrap(CalciteConnection.class);
    SchemaPlus rootSchema = calciteConnection.getRootSchema();
    SchemaPlus schema = rootSchema.add(schemaName, new AbstractSchema());
    final TableFunction table = TableFunctionImpl.create(Smalls.MAZE_METHOD);
    schema.add(funcName, table);
    schema.add(anotherName, table);
    final TableFunction table2 =
        TableFunctionImpl.create(Smalls.MAZE3_METHOD);
    schema.add(funcName, table2);

    final CalciteServerStatement statement =
        connection.createStatement().unwrap(CalciteServerStatement.class);
    final CalcitePrepare.Context prepareContext =
        statement.createPrepareContext();
    final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
    CalciteCatalogReader reader =
        new CalciteCatalogReader(prepareContext.getRootSchema(),
            ImmutableList.of(), typeFactory, prepareContext.config());

    final List<SqlOperator> operatorList = new ArrayList<>();
    SqlIdentifier myFuncIdentifier =
        new SqlIdentifier(Lists.newArrayList(schemaName, funcName), null,
            SqlParserPos.ZERO, null);
    reader.lookupOperatorOverloads(myFuncIdentifier,
        SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION, SqlSyntax.FUNCTION,
        operatorList, nameMatcher);
    checkFunctionType(2, funcName, operatorList);

    operatorList.clear();
    reader.lookupOperatorOverloads(myFuncIdentifier,
        SqlFunctionCategory.USER_DEFINED_FUNCTION, SqlSyntax.FUNCTION,
        operatorList, nameMatcher);
    checkFunctionType(0, null, operatorList);

    operatorList.clear();
    SqlIdentifier anotherFuncIdentifier =
        new SqlIdentifier(Lists.newArrayList(schemaName, anotherName), null,
            SqlParserPos.ZERO, null);
    reader.lookupOperatorOverloads(anotherFuncIdentifier,
        SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION, SqlSyntax.FUNCTION,
        operatorList, nameMatcher);
    checkFunctionType(1, anotherName, operatorList);
  }
}