Skip to content

Commit

Permalink
chore: remove SqlFormatInjector as obsolete (#8931)
Browse files Browse the repository at this point in the history
  • Loading branch information
vcrfxia committed Mar 31, 2022
1 parent 11ede7c commit 1c6caa1
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 96 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,8 @@ public void shouldMaintainOrderOfReturnedQueries() {

// Then:
assertThat(queries, hasSize(2));
assertThat(queries.get(0).getStatementString(), containsString("CREATE STREAM FOO"));
assertThat(queries.get(1).getStatementString(), containsString("CREATE STREAM BAR"));
assertThat(queries.get(0).getStatementString(), containsString("create stream foo"));
assertThat(queries.get(1).getStatementString(), containsString("create stream bar"));
}

@Test(expected = KsqlStatementException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,8 @@ private static ExecuteResult execute(
schemaInjector
.map(injector -> injector.inject(withFormats))
.orElse((ConfiguredStatement) withFormats);
final ConfiguredStatement<?> reformatted =
new SqlFormatInjector(executionContext).inject(withSchema);
try {
return executionContext.execute(serviceContext, reformatted);
return executionContext.execute(serviceContext, withSchema);
} catch (final KsqlStatementException e) {
// use the original statement text in the exception so that tests
// can easily check that the failed statement is the input statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import io.confluent.ksql.config.SessionConfig;
import io.confluent.ksql.engine.KsqlEngine;
import io.confluent.ksql.engine.KsqlPlan;
import io.confluent.ksql.engine.SqlFormatInjector;
import io.confluent.ksql.engine.StubInsertValuesExecutor;
import io.confluent.ksql.execution.ddl.commands.KsqlTopic;
import io.confluent.ksql.execution.json.PlanJsonMapper;
Expand Down Expand Up @@ -490,14 +489,12 @@ private PlannedStatement planStatement(final ParsedStatement stmt) {
schemaInjector
.map(injector -> injector.inject(withFormats))
.orElse((ConfiguredStatement) withFormats);
final ConfiguredStatement<?> reformatted =
new SqlFormatInjector(executionContext).inject(withSchema);

final KsqlPlan plan = executionContext
.plan(executionContext.getServiceContext(), reformatted);
.plan(executionContext.getServiceContext(), withSchema);

return new PlannedStatement(
ConfiguredKsqlPlan.of(rewritePlan(plan), reformatted.getSessionConfig())
ConfiguredKsqlPlan.of(rewritePlan(plan), withSchema.getSessionConfig())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void shouldPlanTestCase() {
);
assertThat(
asList.get(1).getPlan().getStatementText(),
startsWith("CREATE STREAM S1 AS SELECT")
startsWith("CREATE STREAM S1 as SELECT")
);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@
],
"expectedException": {
"type": "io.confluent.ksql.util.KsqlStatementException",
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`F1` INTEGER KEY, `F2` INTEGER KEY], features=[]}\nreason: The 'KAFKA' format only supports a single field. Got: [`F1` INTEGER KEY, `F2` INTEGER KEY]\nStatement: CREATE TABLE OUTPUT AS SELECT\n TEST.F2 F2,\n TEST.F1 F1,\n (TEST.F2 + TEST.F1) KSQL_COL_0,\n COUNT(*) KSQL_COL_1\nFROM TEST TEST\nGROUP BY TEST.F1, TEST.F2\nEMIT CHANGES"
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`F1` INTEGER KEY, `F2` INTEGER KEY], features=[]}\nreason: The 'KAFKA' format only supports a single field. Got: [`F1` INTEGER KEY, `F2` INTEGER KEY]\nStatement: CREATE TABLE OUTPUT AS SELECT f2, f1, f2+f1, COUNT(*) FROM TEST GROUP BY f1, f2;"
}
},
{
Expand Down Expand Up @@ -606,7 +606,7 @@
],
"expectedException": {
"type": "io.confluent.ksql.util.KsqlStatementException",
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`KEY` DECIMAL(2, 1) KEY], features=[]}\nreason: The 'KAFKA' format does not support type 'DECIMAL'\nStatement: CREATE TABLE OUTPUT AS SELECT\n TEST.F2 KEY,\n COUNT(*) TOTAL\nFROM TEST TEST\nGROUP BY TEST.F2\nEMIT CHANGES"
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`KEY` DECIMAL(2, 1) KEY], features=[]}\nreason: The 'KAFKA' format does not support type 'DECIMAL'\nStatement: CREATE TABLE OUTPUT AS SELECT f2 AS key, COUNT(*) AS total FROM TEST GROUP BY f2;"
}
},
{
Expand Down Expand Up @@ -688,7 +688,7 @@
],
"expectedException": {
"type": "io.confluent.ksql.util.KsqlStatementException",
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`K1` INTEGER KEY, `K2` INTEGER KEY], features=[]}\nreason: The 'KAFKA' format only supports a single field. Got: [`K1` INTEGER KEY, `K2` INTEGER KEY]\nStatement: CREATE TABLE OUTPUT WITH (KEY_FORMAT='KAFKA') AS SELECT\n TEST.F1 K1,\n TEST.F2 K2,\n COUNT(*) TOTAL\nFROM TEST TEST\nGROUP BY TEST.F1, TEST.F2\nEMIT CHANGES"
"message": "Key format does not support schema.\nformat: KAFKA\nschema: Persistence{columns=[`K1` INTEGER KEY, `K2` INTEGER KEY], features=[]}\nreason: The 'KAFKA' format only supports a single field. Got: [`K1` INTEGER KEY, `K2` INTEGER KEY]\nStatement: CREATE TABLE OUTPUT WITH (KEY_FORMAT='KAFKA') AS SELECT f1 AS k1, f2 AS k2, COUNT(*) AS total FROM TEST GROUP BY f1, f2;"
}
},
{
Expand Down

0 comments on commit 1c6caa1

Please sign in to comment.