You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2024/10/05 01:30:49 UTC
(calcite) branch main updated (3471ac1da4 -> 2ce9ba42da)
This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
omit 3471ac1da4 [CALCITE-6603] Lattice SQL supports generation of specified dialects
omit fc271c97b1 Add Snowflake and Redshift as constraints
new cb698c849c In linter that checks terminology, add terms 'Snowflake' and 'Redshift'
new 2ce9ba42da [CALCITE-6603] Lattice SQL supports generation of specified dialects
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (3471ac1da4)
\
N -- N -- N refs/heads/main (2ce9ba42da)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
(calcite) 01/02: In linter that checks terminology, add terms 'Snowflake' and 'Redshift'
Posted by jh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
commit cb698c849c9c21ff9b2f8baf1ba3770711340232
Author: cc.cai <cc...@aftership.com>
AuthorDate: Mon Sep 30 18:11:56 2024 +0800
In linter that checks terminology, add terms 'Snowflake' and 'Redshift'
---
core/src/test/java/org/apache/calcite/test/LintTest.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/core/src/test/java/org/apache/calcite/test/LintTest.java b/core/src/test/java/org/apache/calcite/test/LintTest.java
index a2605fa6e5..56fa317b63 100644
--- a/core/src/test/java/org/apache/calcite/test/LintTest.java
+++ b/core/src/test/java/org/apache/calcite/test/LintTest.java
@@ -374,6 +374,8 @@ class LintTest {
TERMINOLOGY_MAP.put("presto", "Presto");
TERMINOLOGY_MAP.put("oracle", "Oracle");
TERMINOLOGY_MAP.put("bigquery", "BigQuery");
+ TERMINOLOGY_MAP.put("redshift", "Redshift");
+ TERMINOLOGY_MAP.put("snowflake", "Snowflake");
}
private static void checkMessage(String subject, String body,
(calcite) 02/02: [CALCITE-6603] Lattice SQL supports generation of specified dialects
Posted by jh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
commit 2ce9ba42da4bec48f4252eb178a5377b941fe41f
Author: YiwenWu <yi...@gmail.com>
AuthorDate: Sun Sep 29 17:19:08 2024 +0800
[CALCITE-6603] Lattice SQL supports generation of specified dialects
---
.../org/apache/calcite/materialize/Lattice.java | 9 +++++-
.../java/org/apache/calcite/test/LatticeTest.java | 33 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/calcite/materialize/Lattice.java b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
index e8e8de80d1..2f9b1c6eff 100644
--- a/core/src/main/java/org/apache/calcite/materialize/Lattice.java
+++ b/core/src/main/java/org/apache/calcite/materialize/Lattice.java
@@ -251,6 +251,14 @@ public class Lattice {
* given set of columns and measures, optionally grouping. */
public String sql(ImmutableBitSet groupSet, boolean group,
List<Measure> aggCallList) {
+ final SqlDialect dialect = SqlDialect.DatabaseProduct.CALCITE.getDialect();
+ return sql(groupSet, group, aggCallList, dialect);
+ }
+
+ /** Generates a SQL query to populate a tile of the lattice specified by a
+ * given set of columns and measures, optionally grouping and dialect. */
+ public String sql(ImmutableBitSet groupSet, boolean group,
+ List<Measure> aggCallList, SqlDialect dialect) {
final List<LatticeNode> usedNodes = new ArrayList<>();
if (group) {
final ImmutableBitSet.Builder columnSetBuilder = groupSet.rebuild();
@@ -277,7 +285,6 @@ public class Lattice {
usedNodes.addAll(rootNode.descendants);
}
- final SqlDialect dialect = SqlDialect.DatabaseProduct.CALCITE.getDialect();
final StringBuilder buf = new StringBuilder("SELECT ");
final StringBuilder groupBuf = new StringBuilder("\nGROUP BY ");
int k = 0;
diff --git a/core/src/test/java/org/apache/calcite/test/LatticeTest.java b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
index bb50650d62..1a16626150 100644
--- a/core/src/test/java/org/apache/calcite/test/LatticeTest.java
+++ b/core/src/test/java/org/apache/calcite/test/LatticeTest.java
@@ -25,6 +25,8 @@ import org.apache.calcite.plan.RelOptUtil;
import org.apache.calcite.rel.rules.materialize.MaterializedViewRules;
import org.apache.calcite.runtime.Hook;
import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlDialect.DatabaseProduct;
import org.apache.calcite.test.schemata.foodmart.FoodmartSchema;
import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.TestUtil;
@@ -227,6 +229,37 @@ class LatticeTest {
});
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6603">[CALCITE-6603]
+ * Lattice SQL supports generation of specified dialects</a>. */
+ @Test void testLatticeSqlWithDialect() throws Exception {
+ final SqlDialect dialect = DatabaseProduct.SPARK.getDialect();
+ modelWithLattice("EMPLOYEES", "select * from \"foodmart\".\"days\"")
+ .doWithConnection(c -> {
+ final SchemaPlus schema = c.getRootSchema();
+ final SchemaPlus adhoc =
+ requireNonNull(schema.getSubSchema("adhoc"));
+ assertThat(adhoc.getTableNames().contains("EMPLOYEES"), is(true));
+ final CalciteSchema adhocSchema =
+ requireNonNull(adhoc.unwrap(CalciteSchema.class));
+ final Map.Entry<String, CalciteSchema.LatticeEntry> entry =
+ adhocSchema.getLatticeMap().firstEntry();
+ final Lattice lattice = entry.getValue().getLattice();
+ final String sql = "SELECT `days`.`day`\n"
+ + "FROM `foodmart`.`days` AS `days`\n"
+ + "GROUP BY `days`.`day`";
+ assertThat(
+ lattice.sql(ImmutableBitSet.of(0), true,
+ ImmutableList.of(), dialect), is(sql));
+ final String sql2 = "SELECT `days`.`day`, `days`.`week_day`\n"
+ + "FROM `foodmart`.`days` AS `days`";
+ assertThat(
+ lattice.sql(ImmutableBitSet.of(0, 1), false,
+ ImmutableList.of(), dialect),
+ is(sql2));
+ });
+ }
+
/** Tests some of the properties of the {@link Lattice} data structure. */
@Test void testLattice() throws Exception {
modelWithLattice("star",