You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Yogendra Sharma <sy...@live.com> on 2022/02/18 21:38:17 UTC

Query Validation Failure

Hi Community,

I am trying to understand the code written in SqlValidatorImpl class. I wrote a simple piece of code to test/debug this, and to my surprise, even that simple code is failing with error-

"No match found for function signature ="

I simply calling Validator.validate(node)  on a SqlNode received after parsing a SELECT query with WHERE clause.

public void validate() throws Exception {
Map<String, Table> tableMap = new HashMap<>();
tableMap.put("TAB1", this.createTable("TAB1", 1));
tableMap.put("TAB2", this.createTable("TAB2", 2));

SimpleSchema schema = new SimpleSchema("Simple", tableMap);
RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl();

CalciteSchema rootSchema = CalciteSchema.createRootSchema(false, false);
rootSchema.add(schema.getSchemaName(), schema);

Prepare.CatalogReader catalogReader = new CalciteCatalogReader(rootSchema,
Collections.singletonList(schema.getSchemaName()), typeFactory, this.config());

SqlValidator.Config validatorConfig = SqlValidator.Config.DEFAULT
.withLenientOperatorLookup(this.config().lenientOperatorLookup())
.withSqlConformance(this.config().conformance())
.withDefaultNullCollation(this.config().defaultNullCollation())
.withIdentifierExpansion(true);

SqlOperatorTable opTable = SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(SqlLibrary.ORACLE);

SqlValidator validator = SqlValidatorUtil.newValidator(opTable, catalogReader, typeFactory, validatorConfig);

SqlNode node = this.parse("SELECT * FROM TAB1 t1 WHERE t1.COL11 = 100");
validator.validate(node);
System.out.println("Done");
}


Thank you!!

Re: Query Validation Failure

Posted by Yogendra Sharma <sy...@live.com>.
Turned out to be the operator table trick. I was passing the wrong operator table.

Changing the operator table to below fixed it.
SqlOperatorTable operatorTable = SqlStdOperatorTable.instance();

Thank you!
________________________________
From: Yogendra Sharma <sy...@live.com>
Sent: Saturday, February 19, 2022 3:08 AM
To: dev@calcite.apache.org <de...@calcite.apache.org>
Subject: Query Validation Failure

Hi Community,

I am trying to understand the code written in SqlValidatorImpl class. I wrote a simple piece of code to test/debug this, and to my surprise, even that simple code is failing with error-

"No match found for function signature ="

I simply calling Validator.validate(node)  on a SqlNode received after parsing a SELECT query with WHERE clause.

public void validate() throws Exception {
Map<String, Table> tableMap = new HashMap<>();
tableMap.put("TAB1", this.createTable("TAB1", 1));
tableMap.put("TAB2", this.createTable("TAB2", 2));

SimpleSchema schema = new SimpleSchema("Simple", tableMap);
RelDataTypeFactory typeFactory = new JavaTypeFactoryImpl();

CalciteSchema rootSchema = CalciteSchema.createRootSchema(false, false);
rootSchema.add(schema.getSchemaName(), schema);

Prepare.CatalogReader catalogReader = new CalciteCatalogReader(rootSchema,
Collections.singletonList(schema.getSchemaName()), typeFactory, this.config());

SqlValidator.Config validatorConfig = SqlValidator.Config.DEFAULT
.withLenientOperatorLookup(this.config().lenientOperatorLookup())
.withSqlConformance(this.config().conformance())
.withDefaultNullCollation(this.config().defaultNullCollation())
.withIdentifierExpansion(true);

SqlOperatorTable opTable = SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(SqlLibrary.ORACLE);

SqlValidator validator = SqlValidatorUtil.newValidator(opTable, catalogReader, typeFactory, validatorConfig);

SqlNode node = this.parse("SELECT * FROM TAB1 t1 WHERE t1.COL11 = 100");
validator.validate(node);
System.out.println("Done");
}


Thank you!!