It may be a bug caused by CALCITE-4427 <https://issues.apache.org/jira/browse/CALCITE-4427>, I think lookupSubjectRoutines behavior is a bit strange. when found routines are less than two, It returns directly whatever the routine SqlKind is. otherwise filtered by SqlKind. This behavior may cause empty routine results when all candidates are filtered out. @Julian, could you help the exception to be fixed?
wrstrs <[email protected]> 于2021年7月27日周二 下午3:33写道: > Hi, all > > how to solve this problem? > > > > > my code: > String sql = "select UNIX_TIMESTAMP(concat(substr('2021-07-27 > 12:12:12',0,11),'09:00:00'))"; > > SqlOperatorTable opTab = > > SqlLibraryOperatorTableFactory.INSTANCE.getOperatorTable(EnumSet.of( > SqlLibrary.HIVE, > SqlLibrary.SPARK, SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE, > SqlLibrary.MYSQL, SqlLibrary.STANDARD)); > SchemaPlus rootSchema = Frameworks.createRootSchema(true); > > FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder() > .defaultSchema(rootSchema) > .operatorTable(opTab) > .build(); > > Planner planner = Frameworks.getPlanner(frameworkConfig); > SqlNode sqlNode = planner.parse(sql); > SqlNode validateSqlNode = planner.validate(sqlNode); > > > > throw exception: > > Exception in thread "main" org.apache.calcite.tools.ValidationException: > java.lang.ClassCastException: > org.apache.calcite.sql.type.FamilyOperandTypeChecker cannot be cast to > org.apache.calcite.sql.type.SqlOperandMetadata > > at > org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:228) > > Caused by: java.lang.ClassCastException: > org.apache.calcite.sql.type.FamilyOperandTypeChecker cannot be cast to > org.apache.calcite.sql.type.SqlOperandMetadata > > at > org.apache.calcite.sql.validate.implicit.TypeCoercionImpl.userDefinedFunctionCoercion(TypeCoercionImpl.java:589) > > at > org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:303) > > at > org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:231)
