Fedor Malchikov created IGNITE-14336: -----------------------------------------
Summary: SQL. Calcite: can't find a column during the query if it was added via alter table Key: IGNITE-14336 URL: https://issues.apache.org/jira/browse/IGNITE-14336 Project: Ignite Issue Type: Bug Components: sql Reporter: Fedor Malchikov {code:java} 52/627 CREATE TABLE t1 ( id INT NOT NULL, tinyint_col1 TINYINT, PRIMARY KEY (id) ) ; No rows affected (0.377 seconds) 53/627 ALTER TABLE t1 ADD COLUMN new_col1 BOOLEAN; No rows affected (0.037 seconds) 54/627 # DATA LOADING FOR t1 55/627 INSERT INTO t1 (id,tinyint_col1) VALUES (2,0),(3,-1),(4,1),(5,-128),(-6,NULL),(7,-127),(8,126),(9,9),(10,10),(-11,NULL),(12,12),(13,13),(14,14),(15,15),(-16,NULL),(17,17),(18,18),(19,19),(20,20),(-21,NULL),(22,22),(23,23),(24,24),(25,25),(-26,NULL),(27,27),(28,28),(29,29),(30,30),(-31,NULL),(32,32),(33,33),(34,34),(35,35),(-36,NULL),(37,37),(38,38),(39,39),(40,40),(-41,NULL),(42,42),(43,43),(44,44),(45,45),(-46,NULL),(47,47),(48,48),(49,49),(50,50),(-51,NULL),(52,52),(53,53),(54,54),(55,55),(-56,NULL),(57,57),(58,58),(59,59),(60,60),(-61,NULL),(62,62),(63,63),(64,64),(65,65),(-66,NULL),(67,67),(68,68),(69,69),(70,70),(-71,NULL),(72,72),(73,73),(74,74),(75,75),(-76,NULL),(77,77),(78,78),(79,79),(80,80),(-81,NULL),(82,82),(83,83),(84,84),(85,85),(-86,NULL),(87,87),(88,88),(89,89),(90,90),(-91,NULL),(92,92),(93,93),(94,94),(95,95),(-96,NULL),(97,97),(98,98),(99,99),(100,100),(-101,NULL),(102,102),(103,103),(104,104),(105,105),(-106,NULL),(107,107),(108,108),(109,109),(110,110),(-111,NULL),(112,112),(113,113),(114,114),(115,115),(-116,NULL),(117,117),(118,118),(119,119),(120,120),(-121,NULL),(122,122),(123,123),(124,124),(125,125),(-126,NULL),(127,127),(128,-1),(129,2),(130,3),(-131,NULL),(132,5),(133,-6),(134,7),(135,8),(-136,NULL),(137,10),(138,-11),(139,12),(140,13),(-141,NULL),(142,15),(143,-16),(144,17),(145,18),(-146,NULL),(147,20),(148,-21),(149,22),(150,23),(-151,NULL); 150 rows affected (0.481 seconds) 56/627 ALTER TABLE t1 ADD COLUMN new_col2 BOOLEAN; No rows affected (0.013 seconds) 57/627 SELECT new_col1, new_col2 FROM t1 ORDER BY id; Error: Failed to plan query. (state=50000,code=1)java.sql.SQLException: Failed to plan query. at org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:1009) at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:234) at org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:560) at sqlline.Commands.execute(Commands.java:823) at sqlline.Commands.sql(Commands.java:733) at sqlline.SqlLine.dispatch(SqlLine.java:795) at sqlline.SqlLine.runCommands(SqlLine.java:1706) at sqlline.Commands.run(Commands.java:1317) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38) at sqlline.SqlLine.dispatch(SqlLine.java:791) at sqlline.SqlLine.initArgs(SqlLine.java:595) at sqlline.SqlLine.begin(SqlLine.java:643) at sqlline.SqlLine.start(SqlLine.java:373) at sqlline.SqlLine.main(SqlLine.java:265) {code} Error in logs: {code:java} [03:59:26,337][INFO][client-connector-#172][CalciteQueryProcessor] Going to execute new query with Calcite: sql=SELECT new_col1, new_col2 FROM t1 ORDER BY id [03:59:26,605][SEVERE][client-connector-#172][JdbcRequestHandler] Failed to execute SQL query [reqId=5, req=JdbcQueryExecuteRequest [schemaName=PUBLIC, pageSize=1024, maxRows=0, sqlQry=SELECT new_col1, new_col2 FROM t1 ORDER BY id, args=Object[] [], stmtType=ANY_STATEMENT_TYPE, autoCommit=true, partResReq=false, explicitTimeout=false, super=JdbcRequest [type=2, reqId=5]]] class org.apache.ignite.internal.processors.query.IgniteSQLException: Failed to plan query. at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:522) at org.apache.ignite.internal.processors.query.calcite.prepare.QueryPlanCacheImpl.queryPlan(QueryPlanCacheImpl.java:84) at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.executeQuery(ExecutionServiceImpl.java:379) at org.apache.ignite.internal.processors.query.calcite.CalciteQueryProcessor.query(CalciteQueryProcessor.java:249) at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.querySqlFields(JdbcRequestHandler.java:790) at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.executeQuery(JdbcRequestHandler.java:673) at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.doHandle(JdbcRequestHandler.java:341) at org.apache.ignite.internal.processors.odbc.jdbc.JdbcRequestHandler.handle(JdbcRequestHandler.java:278) at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:202) at org.apache.ignite.internal.processors.odbc.ClientListenerNioListener.onMessage(ClientListenerNioListener.java:56) at org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279) at org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109) at org.apache.ignite.internal.util.nio.GridNioAsyncNotifyFilter$3.body(GridNioAsyncNotifyFilter.java:97) at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:120) at org.apache.ignite.internal.util.worker.GridWorkerPool$1.run(GridWorkerPool.java:70) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 8 to line 1, column 15: Column 'NEW_COL1' not found in any table at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:883) at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:868) at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5043) at org.apache.calcite.sql.validate.DelegatingScope.fullyQualify(DelegatingScope.java:259) at org.apache.calcite.sql.validate.SqlValidatorImpl$Expander.visit(SqlValidatorImpl.java:6015) at org.apache.calcite.sql.validate.SqlValidatorImpl$SelectExpander.visit(SqlValidatorImpl.java:6178) at org.apache.calcite.sql.validate.SqlValidatorImpl$SelectExpander.visit(SqlValidatorImpl.java:6164) at org.apache.calcite.sql.SqlIdentifier.accept(SqlIdentifier.java:320) at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectExpr(SqlValidatorImpl.java:5600) at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:411) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:4205) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3474) at org.apache.ignite.internal.processors.query.calcite.prepare.IgniteSqlValidator.validateSelect(IgniteSqlValidator.java:146) at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60) at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1067) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1041) at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:232) at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1016) at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:724) at org.apache.ignite.internal.processors.query.calcite.prepare.IgnitePlanner.validateAndGetTypeMetadata(IgnitePlanner.java:196) at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:565) at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareSingle(ExecutionServiceImpl.java:543) at org.apache.ignite.internal.processors.query.calcite.exec.ExecutionServiceImpl.prepareQuery(ExecutionServiceImpl.java:502) ... 17 more Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Column 'NEW_COL1' not found in any table at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:467) at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:560) ... 41 more {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)