[ https://issues.apache.org/jira/browse/CALCITE-5796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17736693#comment-17736693 ]
Jiajun Xie commented on CALCITE-5796: ------------------------------------- When we execute `JdbcFrontLinqBackTest#testDelete`(Effective UT), the row is employee class, not object array. I think we should use `EnumerableDefaults#except` to delete row in `EnumerableTableModify#implement`. > DELETE statement is not effective > ---------------------------------- > > Key: CALCITE-5796 > URL: https://issues.apache.org/jira/browse/CALCITE-5796 > Project: Calcite > Issue Type: Bug > Components: core, linq4j > Reporter: Jiajun Xie > Priority: Major > Attachments: image-2023-06-24-18-27-57-722.png > > > I try to use `DELETE FROM t`, but the table was not affected. > > {code:java} > static void erase(SqlIdentifier name, CalcitePrepare.Context context) { > // Generate, prepare and execute an "DELETE FROM table" statement. > // (It's a bit inefficient that we convert from SqlNode to SQL and back > // again.) > final FrameworkConfig config = Frameworks.newConfigBuilder() > .defaultSchema(context.getRootSchema().plus()) > .build(); > final Planner planner = Frameworks.getPlanner(config); > try { > final StringBuilder buf = new StringBuilder(); > final SqlWriterConfig writerConfig = > SqlPrettyWriter.config().withAlwaysUseParentheses(false); > final SqlPrettyWriter w = new SqlPrettyWriter(writerConfig, buf); > buf.append("DELETE FROM "); > name.unparse(w, 0, 0); > final String sql = buf.toString(); > final SqlNode query1 = planner.parse(sql); > final SqlNode query2 = planner.validate(query1); > final RelRoot r = planner.rel(query2); > final PreparedStatement prepare = > context.getRelRunner().prepareStatement(r.rel); > int rowCount = prepare.executeUpdate(); > Util.discard(rowCount); > prepare.close(); > } catch (SqlParseException | ValidationException > | RelConversionException | SQLException e) { > throw Util.throwAsRuntime(e); > } > } {code} > > Because we use `EnumerableDefaults#remove()` to delete target rows. > The rows is object array, they can't match. > !image-2023-06-24-18-27-57-722.png! -- This message was sent by Atlassian Jira (v8.20.10#820010)