You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by za...@apache.org on 2021/07/12 10:30:08 UTC
[calcite] branch master updated: [CALCITE-4674] Excess quotes in
generated SQL when STAR is a column alias
This is an automated email from the ASF dual-hosted git repository.
zabetak pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new d7290e7 [CALCITE-4674] Excess quotes in generated SQL when STAR is a column alias
d7290e7 is described below
commit d7290e723a30862da5e69d3b7cc558e22d58b661
Author: Stamatis Zampetakis <za...@gmail.com>
AuthorDate: Thu Jul 1 12:15:01 2021 +0200
[CALCITE-4674] Excess quotes in generated SQL when STAR is a column alias
---
core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java | 3 +--
.../org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java | 10 ++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
index af25ce1..8c7063f 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIdentifier.java
@@ -150,8 +150,7 @@ public class SqlIdentifier extends SqlNode {
/** Converts empty strings in a list of names to stars. */
public static List<String> toStar(List<String> names) {
- return Util.transform(names,
- s -> s.equals("") ? "*" : s.equals("*") ? "\"*\"" : s);
+ return Util.transform(names, s -> s.equals("") ? "*" : s);
}
/**
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 020ac74..54ab21b 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -3035,6 +3035,16 @@ class RelToSqlConverterTest {
sql(query).ok(expected);
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-4674">[CALCITE-4674]
+ * Excess quotes in generated SQL when STAR is a column alias</a>. */
+ @Test void testAliasOnStarNoExcessQuotes() {
+ final String query = "select \"customer_id\" as \"*\" from \"customer\"";
+ final String expected = "SELECT \"customer_id\" AS \"*\"\n"
+ + "FROM \"foodmart\".\"customer\"";
+ sql(query).ok(expected);
+ }
+
@Test void testLiteral() {
checkLiteral("DATE '1978-05-02'");
checkLiteral2("DATE '1978-5-2'", "DATE '1978-05-02'");