Skip to content

Commit

Permalink
fix(ksql-driver): Escape quotes in column names
Browse files Browse the repository at this point in the history
  • Loading branch information
mcheshkov committed Nov 5, 2024
1 parent cfafe12 commit b2ae9b6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/cubejs-ksql-driver/src/KsqlQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class KsqlQuery extends BaseQuery {
}

public escapeColumnName(name: string) {
return `\`${name}\``;
// https://docs.confluent.io/platform/current/ksqldb/reference/sql/lexical-structure.html#ksqldb-lexical-structure-identifiers
// https://github.com/confluentinc/ksql/blob/84afdf1c2504844a15e02643f796288b8b069073/ksqldb-parser/src/main/antlr4/io/confluent/ksql/parser/SqlBase.g4#L378
return `\`${name.replaceAll('`', '``')}\``;
}

public castToString(sql: string) {
Expand Down Expand Up @@ -97,7 +99,7 @@ export class KsqlQuery extends BaseQuery {
}
}
const res = this.evaluateSymbolSqlWithContext(() => [

preAggregation.refreshRangeStart && [this.evaluateSql(cube, preAggregation.refreshRangeStart.sql, {}), [], { external: true }],
preAggregation.refreshRangeEnd && [this.evaluateSql(cube, preAggregation.refreshRangeEnd.sql, {}), [], { external: true }]
], { preAggregationQuery: true });
Expand Down

0 comments on commit b2ae9b6

Please sign in to comment.