You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2025/08/12 19:21:56 UTC

(superset) 01/01: fix(sql): Add Impala dialect support to sqlglot parser

This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch issue32143
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 553aac399e78c3878d14705d0ebe83dafa876cb7
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Tue Aug 12 12:12:54 2025 -0700

    fix(sql): Add Impala dialect support to sqlglot parser
    
    Fixes #32143
    
    The sqlglot SQL parser was missing support for the Impala dialect, causing dataset creation to fail with "Fatal error" for Impala databases. Since Impala's SQL syntax is very similar to Hive, this fix maps the Impala engine to use the Hive dialect in sqlglot.
    
    This allows Impala users to create datasets and use all SQL parsing features that rely on sqlglot.
    
    🤖 Generated with [Claude Code](https://claude.ai/code)
    
    Co-Authored-By: Claude <no...@anthropic.com>
---
 .claude_rc                                  | 40 ++++++++++++++++
 superset-frontend/package-lock.json         |  2 +-
 superset/sql/parse.py                       |  2 +-
 tests/unit_tests/sql/test_impala_dialect.py | 73 +++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+), 2 deletions(-)

diff --git a/.claude_rc b/.claude_rc
new file mode 100644
index 0000000000..0e91c9740d
--- /dev/null
+++ b/.claude_rc
@@ -0,0 +1,40 @@
+# Claude Code RC for issue32143
+
+This is a claudette-managed Apache Superset development environment.
+
+## Project: issue32143
+- Worktree Path: /Users/evan_1/.claudette/worktrees/issue32143
+- Frontend Port: 9008
+- Frontend URL: http://localhost:9008
+
+## Quick Commands
+
+Start services:
+```bash
+claudette docker up
+```
+
+Access frontend:
+```bash
+open http://localhost:9008
+```
+
+Run tests:
+```bash
+# Backend
+pytest tests/unit_tests/
+
+# Frontend
+cd superset-frontend && npm test
+```
+
+## Environment Details
+- Python venv: `.venv/` (auto-activated in claudette shell)
+- Node modules: `superset-frontend/node_modules/`
+- Docker prefix: `issue32143_`
+
+## Development Tips
+- Always use `claudette shell` to work in this project
+- Run `pre-commit run --all-files` before committing
+- Use `claudette docker` instead of docker-compose directly
+- The frontend dev server runs on port 9008 to avoid conflicts
diff --git a/superset-frontend/package-lock.json b/superset-frontend/package-lock.json
index ad6ac17411..5442463535 100644
--- a/superset-frontend/package-lock.json
+++ b/superset-frontend/package-lock.json
@@ -61644,7 +61644,7 @@
         "@storybook/types": "8.4.7",
         "@types/react-loadable": "^5.5.11",
         "core-js": "3.40.0",
-        "gh-pages": "^6.2.0",
+        "gh-pages": "^6.3.0",
         "jquery": "^3.7.1",
         "memoize-one": "^5.2.1",
         "react": "^17.0.2",
diff --git a/superset/sql/parse.py b/superset/sql/parse.py
index bcc6b32382..2485a9b461 100644
--- a/superset/sql/parse.py
+++ b/superset/sql/parse.py
@@ -81,7 +81,7 @@ SQLGLOT_DIALECTS = {
     "hana": Dialects.POSTGRES,
     "hive": Dialects.HIVE,
     # "ibmi": ???
-    # "impala": ???
+    "impala": Dialects.HIVE,
     # "kustosql": ???
     # "kylin": ???
     "mariadb": Dialects.MYSQL,
diff --git a/tests/unit_tests/sql/test_impala_dialect.py b/tests/unit_tests/sql/test_impala_dialect.py
new file mode 100644
index 0000000000..1bf12de61e
--- /dev/null
+++ b/tests/unit_tests/sql/test_impala_dialect.py
@@ -0,0 +1,73 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for Impala dialect support in sqlglot."""
+
+from sqlglot import Dialects
+
+from superset.sql.parse import SQLGLOT_DIALECTS, SQLScript, Table
+
+
+def test_impala_dialect_mapped() -> None:
+    """Test that Impala is correctly mapped to Hive dialect."""
+    assert "impala" in SQLGLOT_DIALECTS
+    assert SQLGLOT_DIALECTS["impala"] == Dialects.HIVE
+
+
+def test_impala_sql_parsing() -> None:
+    """Test that Impala SQL can be parsed without errors."""
+    # Simple SELECT statement
+    sql = "SELECT * FROM my_table"
+    script = SQLScript(sql, "impala")
+    assert len(script.statements) == 1
+    assert not script.has_mutation()
+
+    # JOIN statement (common in Impala)
+    sql = """
+    SELECT t1.col1, t2.col2
+    FROM table1 t1
+    JOIN table2 t2 ON t1.id = t2.id
+    WHERE t1.status = 'active'
+    """
+    script = SQLScript(sql, "impala")
+    assert len(script.statements) == 1
+    assert not script.has_mutation()
+
+    # Test table extraction
+    tables = script.statements[0].tables
+    assert Table("table1") in tables
+    assert Table("table2") in tables
+
+
+def test_impala_insert_statement() -> None:
+    """Test that Impala INSERT statements are detected as mutations."""
+    sql = "INSERT INTO my_table VALUES (1, 'test')"
+    script = SQLScript(sql, "impala")
+    assert script.has_mutation()
+
+
+def test_impala_create_table() -> None:
+    """Test that Impala CREATE TABLE statements work."""
+    sql = """
+    CREATE TABLE IF NOT EXISTS my_table (
+        id INT,
+        name STRING
+    ) STORED AS PARQUET
+    """
+    script = SQLScript(sql, "impala")
+    assert len(script.statements) == 1
+    assert script.has_mutation()