This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new fdff30504b5 branch-3.1: [feature](sql-dialect)support convert hive
view and presto view use sql convertor service #46308 (#52765)
fdff30504b5 is described below
commit fdff30504b5ca8646f7fd06530dd658d4ef5b010
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Fri Jul 4 19:27:35 2025 +0800
branch-3.1: [feature](sql-dialect)support convert hive view and presto view
use sql convertor service #46308 (#52765)
bp #46308
Co-authored-by: Jiwen liu <[email protected]>
---
.../scripts/create_preinstalled_scripts/run73.hql | 21 ++++
.../scripts/create_view_scripts/create_view.hql | 2 +
.../doris/datasource/hive/HMSExternalTable.java | 50 +++++++-
.../doris/nereids/parser/SqlDialectHelper.java | 66 +++++++++++
.../doris/nereids/rules/analysis/BindRelation.java | 5 +-
.../java/org/apache/doris/qe/ConnectProcessor.java | 29 +----
.../datasource/hive/HMSExternalTableTest.java | 126 +++++++++++++++++++++
.../dialect_compatible/sql/clickhouse.out | Bin
.../presto/scalar/AbstractTestRegexpFunctions.out | Bin
.../scalar/TestArrayCombinationsFunction.out | Bin
.../presto/scalar/TestArrayContainsSequence.out | Bin
.../sql/presto/scalar/TestArrayExceptFunction.out | Bin
.../sql/presto/scalar/TestArrayFilterFunction.out | Bin
.../sql/presto/scalar/TestArrayFunctions.out | Bin
.../presto/scalar/TestArrayHistogramFunction.out | Bin
.../sql/presto/scalar/TestArrayMatchFunctions.out | Bin
.../sql/presto/scalar/TestArrayNgramsFunction.out | Bin
.../sql/presto/scalar/TestArrayReduceFunction.out | Bin
.../presto/scalar/TestArrayTransformFunction.out | Bin
.../sql/presto/scalar/TestArrayTrimFunction.out | Bin
.../sql/presto/scalar/TestBitwiseFunctions.out | Bin
.../scalar/TestBlockAndPositionNullConvention.out | Bin
.../sql/presto/scalar/TestConcatWsFunction.out | Bin
.../sql/presto/scalar/TestCustomFunctions.out | Bin
.../sql/presto/scalar/TestDataSizeFunctions.out | Bin
.../sql/presto/scalar/TestDateTimeFunctions.out | Bin
.../sql/presto/scalar/TestIpAddressFunctions.out | Bin
.../sql/presto/scalar/TestIsNullAnnotation.out | Bin
.../sql/presto/scalar/TestJsonExtract.out | Bin
.../sql/presto/scalar/TestJsonFunctions.out | Bin
.../sql/presto/scalar/TestLuhnCheckFunction.out | Bin
.../sql/presto/scalar/TestMapFilterFunction.out | Bin
.../presto/scalar/TestMapTransformKeysFunction.out | Bin
.../scalar/TestMapTransformValuesFunction.out | Bin
.../sql/presto/scalar/TestMathFunctions.out | Bin
.../sql/presto/scalar/TestScalarParser.out | Bin
.../sql/presto/scalar/TestStringFunctions.out | Bin
.../sql/presto/scalar/TestTryFunction.out | Bin
.../sql/presto/scalar/TestTypeOfFunction.out | Bin
.../sql/presto/scalar/TestUrlFunctions.out | Bin
.../sql/presto/scalar/TestVarbinaryFunctions.out | Bin
.../sql/presto/scalar/TestWordStemFunction.out | Bin
.../sql/presto/scalar/TestZipFunction.out | Bin
.../sql/presto/scalar/TestZipWithFunction.out | Bin
.../sql/presto/scalar/date/TestExtract.out | Bin
.../presto/scalar/interval/TestIntervalDayTime.out | Bin
.../scalar/interval/TestIntervalYearMonth.out | Bin
.../sql/presto/scalar/time/TestExtract.out | Bin
.../sql/presto/scalar/time/TestOperators.out | Bin
.../sql/presto/scalar/time/TestTime.out | Bin
.../sql/presto/scalar/timestamp/TestDateTrunc.out | Bin
.../sql/presto/scalar/timestamp/TestExtract.out | Bin
.../scalar/timestamp/TestHumanReadableSeconds.out | Bin
.../sql/presto/scalar/timestamp/TestOperators.out | Bin
.../sql/presto/scalar/timestamp/TestTimestamp.out | Bin
.../presto/scalar/timestamptz/TestAtTimeZone.out | Bin
.../presto/scalar/timestamptz/TestDateTrunc.out | Bin
.../sql/presto/scalar/timestamptz/TestExtract.out | Bin
.../presto/scalar/timestamptz/TestOperators.out | Bin
.../timestamptz/TestTimestampWithTimeZone.out | Bin
.../sql/presto/scalar/timetz/TestAtTimeZone.out | Bin
.../sql/presto/scalar/timetz/TestDateTrunc.out | Bin
.../sql/presto/scalar/timetz/TestExtract.out | Bin
.../sql/presto/scalar/timetz/TestOperators.out | Bin
.../presto/scalar/timetz/TestTimeWithTimeZone.out | Bin
.../scalar/timetz/TestTimestampWithTimeZone.out | Bin
.../sql/test_hive_view_rewrite.out | Bin 0 -> 311 bytes
.../sql_functions/string_functions/test_trim.out | Bin 0 -> 1532 bytes
.../dialect_compatible/sql/clickhouse.sql | 0
.../presto/scalar/AbstractTestRegexpFunctions.sql | 0
.../scalar/TestArrayCombinationsFunction.sql | 0
.../presto/scalar/TestArrayContainsSequence.sql | 0
.../sql/presto/scalar/TestArrayExceptFunction.sql | 0
.../sql/presto/scalar/TestArrayFilterFunction.sql | 0
.../sql/presto/scalar/TestArrayFunctions.sql | 0
.../presto/scalar/TestArrayHistogramFunction.sql | 0
.../sql/presto/scalar/TestArrayMatchFunctions.sql | 0
.../sql/presto/scalar/TestArrayNgramsFunction.sql | 0
.../sql/presto/scalar/TestArrayReduceFunction.sql | 0
.../presto/scalar/TestArrayTransformFunction.sql | 0
.../sql/presto/scalar/TestArrayTrimFunction.sql | 0
.../sql/presto/scalar/TestBitwiseFunctions.sql | 0
.../scalar/TestBlockAndPositionNullConvention.sql | 0
.../sql/presto/scalar/TestConcatWsFunction.sql | 0
.../sql/presto/scalar/TestCustomFunctions.sql | 0
.../sql/presto/scalar/TestDataSizeFunctions.sql | 0
.../sql/presto/scalar/TestDateTimeFunctions.sql | 0
.../sql/presto/scalar/TestIpAddressFunctions.sql | 0
.../sql/presto/scalar/TestIsNullAnnotation.sql | 0
.../sql/presto/scalar/TestJsonExtract.sql | 0
.../sql/presto/scalar/TestJsonFunctions.sql | 0
.../sql/presto/scalar/TestLuhnCheckFunction.sql | 0
.../sql/presto/scalar/TestMapFilterFunction.sql | 0
.../presto/scalar/TestMapTransformKeysFunction.sql | 0
.../scalar/TestMapTransformValuesFunction.sql | 0
.../sql/presto/scalar/TestMathFunctions.sql | 0
.../sql/presto/scalar/TestScalarParser.sql | 0
.../sql/presto/scalar/TestStringFunctions.sql | 0
.../sql/presto/scalar/TestTryFunction.sql | 0
.../sql/presto/scalar/TestTypeOfFunction.sql | 0
.../sql/presto/scalar/TestUrlFunctions.sql | 0
.../sql/presto/scalar/TestVarbinaryFunctions.sql | 0
.../sql/presto/scalar/TestWordStemFunction.sql | 0
.../sql/presto/scalar/TestZipFunction.sql | 0
.../sql/presto/scalar/TestZipWithFunction.sql | 0
.../sql/presto/scalar/date/TestExtract.sql | 0
.../presto/scalar/interval/TestIntervalDayTime.sql | 0
.../scalar/interval/TestIntervalYearMonth.sql | 0
.../sql/presto/scalar/time/TestExtract.sql | 0
.../sql/presto/scalar/time/TestOperators.sql | 0
.../sql/presto/scalar/time/TestTime.sql | 0
.../sql/presto/scalar/timestamp/TestDateTrunc.sql | 0
.../sql/presto/scalar/timestamp/TestExtract.sql | 0
.../scalar/timestamp/TestHumanReadableSeconds.sql | 0
.../sql/presto/scalar/timestamp/TestOperators.sql | 0
.../sql/presto/scalar/timestamp/TestTimestamp.sql | 0
.../presto/scalar/timestamptz/TestAtTimeZone.sql | 0
.../presto/scalar/timestamptz/TestDateTrunc.sql | 0
.../sql/presto/scalar/timestamptz/TestExtract.sql | 0
.../presto/scalar/timestamptz/TestOperators.sql | 0
.../timestamptz/TestTimestampWithTimeZone.sql | 0
.../sql/presto/scalar/timetz/TestExtract.sql | 0
.../sql/presto/scalar/timetz/TestOperators.sql | 0
.../presto/scalar/timetz/TestTimeWithTimeZone.sql | 0
.../sql/test_hive_view_rewrite.groovy | 48 ++++++++
125 files changed, 317 insertions(+), 30 deletions(-)
diff --git
a/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_scripts/run73.hql
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_scripts/run73.hql
new file mode 100644
index 00000000000..8fb0e372835
--- /dev/null
+++
b/docker/thirdparties/docker-compose/hive/scripts/create_preinstalled_scripts/run73.hql
@@ -0,0 +1,21 @@
+CREATE TABLE employees (
+ id INT,
+ name VARCHAR(100),
+ department VARCHAR(100),
+ salary DECIMAL(10,2),
+ hire_date DATE
+);
+
+
+INSERT INTO employees VALUES
+ (1, 'John Doe', 'IT', 75000.00, '2020-01-15'),
+ (2, 'Jane Smith', 'HR', 65000.00, '2019-03-20'),
+ (3, 'Bob Johnson', 'IT', 80000.00, '2021-05-10'),
+ (4, 'Alice Brown', 'Finance', 70000.00, '2020-11-30'),
+ (5, 'Charlie Wilson', 'HR', 62000.00, '2022-01-05');
+
+
+
+msck repair table employees;
+
+
diff --git
a/docker/thirdparties/docker-compose/hive/scripts/create_view_scripts/create_view.hql
b/docker/thirdparties/docker-compose/hive/scripts/create_view_scripts/create_view.hql
index 221b536e263..5f9d5499d15 100644
---
a/docker/thirdparties/docker-compose/hive/scripts/create_view_scripts/create_view.hql
+++
b/docker/thirdparties/docker-compose/hive/scripts/create_view_scripts/create_view.hql
@@ -4,3 +4,5 @@ create view test_view2 as select * from default.sale_table;
create view test_view3 as select * from sale_table where
bill_code="bill_code1";
create view test_view4 as select parquet_zstd_all_types.t_int,
parquet_zstd_all_types.t_varchar from parquet_zstd_all_types join
multi_catalog.parquet_all_types on parquet_zstd_all_types.t_varchar =
parquet_all_types.t_varchar order by t_int limit 10;
create view unsupported_view as select bill_code from sale_table union all
select t_varchar from multi_catalog.parquet_all_types order by bill_code limit
10;
+create view department_view as select department,length(department) as
department_length,trunc(hire_date,'YEAR') as year from default.employees;
+create view department_nesting_view as select
department,trunc(to_date(year),'YEAR') as year,count(*) as
emp_count,avg(department_length) as avg_dept_name_length from department_view
group by department, year order by year, department;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
index f56145dfdba..4504e2a1f34 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HMSExternalTable.java
@@ -71,6 +71,8 @@ import com.google.common.collect.BiMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -93,7 +95,9 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
+import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -499,9 +503,51 @@ public class HMSExternalTable extends ExternalTable
implements MTMVRelatedTableI
public String getViewText() {
String viewText = getViewExpandedText();
if (StringUtils.isNotEmpty(viewText)) {
- return viewText;
+ if (!viewText.equals("/* Presto View */")) {
+ return viewText;
+ }
+ }
+
+ String originalText = getViewOriginalText();
+ return parseTrinoViewDefinition(originalText);
+ }
+
+ /**
+ * Parse Trino/Presto view definition from the original text.
+ * The definition is stored in the format: /* Presto View:
<base64-encoded-json> * /
+ *
+ * The base64 encoded JSON contains the following fields:
+ * {
+ * "originalSql": "SELECT * FROM employees", // The original SQL
statement
+ * "catalog": "hive", // The data catalog name
+ * "schema": "mmc_hive", // The schema name
+ * ...
+ * }
+ *
+ * @param originalText The original view definition text
+ * @return The parsed SQL statement, or original text if parsing fails
+ */
+ private String parseTrinoViewDefinition(String originalText) {
+ if (originalText == null || !originalText.contains("/* Presto View:
")) {
+ return originalText;
+ }
+
+ try {
+ String base64String = originalText.substring(
+ originalText.indexOf("/* Presto View: ") + "/* Presto
View: ".length(),
+ originalText.lastIndexOf(" */")
+ ).trim();
+ byte[] decodedBytes = Base64.getDecoder().decode(base64String);
+ String decodedString = new String(decodedBytes,
StandardCharsets.UTF_8);
+ JsonObject jsonObject = new Gson().fromJson(decodedString,
JsonObject.class);
+
+ if (jsonObject.has("originalSql")) {
+ return jsonObject.get("originalSql").getAsString();
+ }
+ } catch (Exception e) {
+ LOG.warn("Decoding Presto view definition failed", e);
}
- return getViewOriginalText();
+ return originalText;
}
public String getViewExpandedText() {
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/SqlDialectHelper.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/SqlDialectHelper.java
new file mode 100644
index 00000000000..c959982e254
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/SqlDialectHelper.java
@@ -0,0 +1,66 @@
+// 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.
+
+package org.apache.doris.nereids.parser;
+
+import org.apache.doris.catalog.Env;
+import org.apache.doris.plugin.DialectConverterPlugin;
+import org.apache.doris.plugin.PluginMgr;
+import org.apache.doris.qe.SessionVariable;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.List;
+import javax.annotation.Nullable;
+
+/**
+ * Helper class for SQL dialect conversion.
+ */
+public class SqlDialectHelper {
+ private static final Logger LOG =
LogManager.getLogger(SqlDialectHelper.class);
+
+ /**
+ * Convert SQL statement based on current SQL dialect
+ *
+ * @param originStmt original SQL statement
+ * @param sessionVariable session variable containing dialect settings
+ * @return converted SQL statement, or original statement if conversion
fails
+ */
+ public static String convertSqlByDialect(String originStmt,
SessionVariable sessionVariable) {
+ String convertedStmt = originStmt;
+ @Nullable Dialect sqlDialect =
Dialect.getByName(sessionVariable.getSqlDialect());
+ if (sqlDialect != null && sqlDialect != Dialect.DORIS) {
+ PluginMgr pluginMgr = Env.getCurrentEnv().getPluginMgr();
+ List<DialectConverterPlugin> plugins =
pluginMgr.getActiveDialectPluginList(sqlDialect);
+ for (DialectConverterPlugin plugin : plugins) {
+ try {
+ String convertedSql = plugin.convertSql(originStmt,
sessionVariable);
+ if (StringUtils.isNotEmpty(convertedSql)) {
+ convertedStmt = convertedSql;
+ break;
+ }
+ } catch (Throwable throwable) {
+ LOG.warn("Convert sql with dialect {} failed, plugin: {},
sql: {}, use origin sql.",
+ sqlDialect, plugin.getClass().getSimpleName(),
originStmt, throwable);
+ }
+ }
+ }
+ return convertedStmt;
+ }
+}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
index 37fdc09989b..3c071058cf9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java
@@ -46,6 +46,7 @@ import org.apache.doris.nereids.analyzer.UnboundResultSink;
import org.apache.doris.nereids.exceptions.AnalysisException;
import org.apache.doris.nereids.hint.LeadingHint;
import org.apache.doris.nereids.parser.NereidsParser;
+import org.apache.doris.nereids.parser.SqlDialectHelper;
import org.apache.doris.nereids.pattern.MatchingContext;
import org.apache.doris.nereids.properties.LogicalProperties;
import org.apache.doris.nereids.properties.PhysicalProperties;
@@ -466,11 +467,12 @@ public class BindRelation extends OneAnalysisRuleFactory {
ConnectContext ctx = cascadesContext.getConnectContext();
String previousCatalog = ctx.getCurrentCatalog().getName();
String previousDb = ctx.getDatabase();
+ String convertedSql = SqlDialectHelper.convertSqlByDialect(ddlSql,
ctx.getSessionVariable());
// change catalog and db to hive catalog and db, so that we can parse
and analyze the view sql in hive context.
ctx.changeDefaultCatalog(hiveCatalog);
ctx.setDatabase(hiveDb);
try {
- return parseAndAnalyzeView(table, ddlSql, cascadesContext);
+ return parseAndAnalyzeView(table, convertedSql, cascadesContext);
} finally {
// restore catalog and db in connect context
ctx.changeDefaultCatalog(previousCatalog);
@@ -536,4 +538,5 @@ public class BindRelation extends OneAnalysisRuleFactory {
return part.getId();
}).collect(ImmutableList.toImmutableList());
}
+
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
index 981d3f3b2c5..98214597252 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
@@ -57,15 +57,13 @@ import org.apache.doris.nereids.StatementContext;
import org.apache.doris.nereids.exceptions.NotSupportedException;
import org.apache.doris.nereids.glue.LogicalPlanAdapter;
import org.apache.doris.nereids.minidump.MinidumpUtils;
-import org.apache.doris.nereids.parser.Dialect;
import org.apache.doris.nereids.parser.NereidsParser;
+import org.apache.doris.nereids.parser.SqlDialectHelper;
import org.apache.doris.nereids.stats.StatsErrorEstimator;
import org.apache.doris.nereids.trees.plans.commands.ExplainCommand;
import org.apache.doris.nereids.trees.plans.commands.PrepareCommand;
import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
import org.apache.doris.nereids.trees.plans.logical.LogicalSqlCache;
-import org.apache.doris.plugin.DialectConverterPlugin;
-import org.apache.doris.plugin.PluginMgr;
import org.apache.doris.proto.Data;
import org.apache.doris.qe.QueryState.MysqlStateType;
import org.apache.doris.qe.cache.CacheAnalyzer;
@@ -81,7 +79,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TException;
@@ -94,7 +91,6 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
-import javax.annotation.Nullable;
/**
* Process one connection, the life cycle is the same as connection
@@ -282,7 +278,7 @@ public abstract class ConnectProcessor {
}
}
- String convertedStmt = convertOriginStmt(originStmt);
+ String convertedStmt =
SqlDialectHelper.convertSqlByDialect(originStmt, ctx.getSessionVariable());
String sqlHash = DigestUtils.md5Hex(convertedStmt);
ctx.setSqlHash(sqlHash);
@@ -463,27 +459,6 @@ public abstract class ConnectProcessor {
return null;
}
- private String convertOriginStmt(String originStmt) {
- String convertedStmt = originStmt;
- @Nullable Dialect sqlDialect =
Dialect.getByName(ctx.getSessionVariable().getSqlDialect());
- if (sqlDialect != null && sqlDialect != Dialect.DORIS) {
- PluginMgr pluginMgr = Env.getCurrentEnv().getPluginMgr();
- List<DialectConverterPlugin> plugins =
pluginMgr.getActiveDialectPluginList(sqlDialect);
- for (DialectConverterPlugin plugin : plugins) {
- try {
- String convertedSql = plugin.convertSql(originStmt,
ctx.getSessionVariable());
- if (StringUtils.isNotEmpty(convertedSql)) {
- convertedStmt = convertedSql;
- break;
- }
- } catch (Throwable throwable) {
- LOG.warn("Convert sql with dialect {} failed, plugin: {},
sql: {}, use origin sql.",
- sqlDialect, plugin.getClass().getSimpleName(),
originStmt, throwable);
- }
- }
- }
- return convertedStmt;
- }
// Use a handler for exception to avoid big try catch block which is a
little hard to understand
protected void handleQueryException(Throwable throwable, String origStmt,
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSExternalTableTest.java
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSExternalTableTest.java
new file mode 100644
index 00000000000..bd29766f39e
--- /dev/null
+++
b/fe/fe-core/src/test/java/org/apache/doris/datasource/hive/HMSExternalTableTest.java
@@ -0,0 +1,126 @@
+// 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.
+
+package org.apache.doris.datasource.hive;
+
+import mockit.Injectable;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * Test class for HMSExternalTable, focusing on view-related functionality
+ */
+public class HMSExternalTableTest {
+ private TestHMSExternalTable table;
+ private static final String TEST_VIEW_TEXT = "SELECT * FROM test_table";
+ private static final String TEST_EXPANDED_VIEW = "/* Presto View */";
+
+ // Real example of a Presto View definition
+ private static final String PRESTO_VIEW_ORIGINAL = "/* Presto View:
eyJvcmlnaW5hbFNxbCI6IlNFTEVDVFxuICBkZXBhcnRtZW50XG4sIGxlbmd0aChkZXBhcnRtZW50KSBkZXBhcnRtZW50X2xlbmd0aFxuLCBkYXRlX3RydW5jKCd5ZWFyJywgaGlyZV9kYXRlKSB5ZWFyXG5GUk9NXG4gIGVtcGxveWVlc1xuIiwiY2F0YWxvZyI6ImhpdmUiLCJzY2hlbWEiOiJtbWNfaGl2ZSIsImNvbHVtbnMiOlt7Im5hbWUiOiJkZXBhcnRtZW50IiwidHlwZSI6InZhcmNoYXIifSx7Im5hbWUiOiJkZXBhcnRtZW50X2xlbmd0aCIsInR5cGUiOiJiaWdpbnQifSx7Im5hbWUiOiJ5ZWFyIiwidHlwZSI6ImRhdGUifV0sIm93bmVyIjoidHJpbm8v
[...]
+
+ // Expected SQL query after decoding and parsing
+ private static final String EXPECTED_SQL = "SELECT\n department\n,
length(department) department_length\n, date_trunc('year', hire_date)
year\nFROM\n employees\n";
+
+ @Injectable
+ private HMSExternalCatalog mockCatalog;
+
+ private HMSExternalDatabase mockDb;
+
+ @BeforeEach
+ public void setUp() {
+ // Create a mock database with minimal required functionality
+ mockDb = new HMSExternalDatabase(mockCatalog, 1L, "test_db",
"remote_test_db") {
+ @Override
+ public String getFullName() {
+ return "test_catalog.test_db";
+ }
+ };
+
+ table = new TestHMSExternalTable(mockCatalog, mockDb);
+ }
+
+ @Test
+ public void testGetViewText_Normal() {
+ // Test regular view text retrieval
+ table.setViewOriginalText(TEST_VIEW_TEXT);
+ table.setViewExpandedText(TEST_VIEW_TEXT);
+ Assertions.assertEquals(TEST_VIEW_TEXT, table.getViewText());
+ }
+
+ @Test
+ public void testGetViewText_PrestoView() {
+ // Test Presto view parsing including base64 decode and JSON extraction
+ table.setViewOriginalText(PRESTO_VIEW_ORIGINAL);
+ table.setViewExpandedText(TEST_EXPANDED_VIEW);
+ Assertions.assertEquals(EXPECTED_SQL, table.getViewText());
+ }
+
+ @Test
+ public void testGetViewText_InvalidPrestoView() {
+ // Test handling of invalid Presto view definition
+ String invalidPrestoView = "/* Presto View: invalid_base64_content */";
+ table.setViewOriginalText(invalidPrestoView);
+ table.setViewExpandedText(TEST_EXPANDED_VIEW);
+ Assertions.assertEquals(invalidPrestoView, table.getViewText());
+ }
+
+ @Test
+ public void testGetViewText_EmptyExpandedView() {
+ // Test handling of empty expanded view text
+ table.setViewOriginalText(TEST_VIEW_TEXT);
+ table.setViewExpandedText("");
+ Assertions.assertEquals(TEST_VIEW_TEXT, table.getViewText());
+ }
+
+ /**
+ * Test implementation of HMSExternalTable that allows setting view texts
+ * Uses parent's getViewText() implementation for actual testing
+ */
+ private static class TestHMSExternalTable extends HMSExternalTable {
+ private String viewExpandedText;
+ private String viewOriginalText;
+
+ public TestHMSExternalTable(HMSExternalCatalog catalog,
HMSExternalDatabase db) {
+ super(1L, "test_table", "test_table", catalog, db);
+ }
+
+ @Override
+ public String getViewExpandedText() {
+ return viewExpandedText;
+ }
+
+ @Override
+ public String getViewOriginalText() {
+ return viewOriginalText;
+ }
+
+ public void setViewExpandedText(String viewExpandedText) {
+ this.viewExpandedText = viewExpandedText;
+ }
+
+ public void setViewOriginalText(String viewOriginalText) {
+ this.viewOriginalText = viewOriginalText;
+ }
+
+ @Override
+ protected synchronized void makeSureInitialized() {
+ this.objectCreated = true;
+ }
+ }
+}
diff --git a/regression-test/data/dialect_compatible/sql/clickhouse.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/clickhouse.out
similarity index 100%
rename from regression-test/data/dialect_compatible/sql/clickhouse.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/clickhouse.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestCustomFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestCustomFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestCustomFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestCustomFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestJsonExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestJsonExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestJsonFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestJsonFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestMathFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMathFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestMathFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestMathFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestScalarParser.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestScalarParser.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestScalarParser.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestScalarParser.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestStringFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestStringFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestStringFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestStringFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestTryFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestTryFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestTryFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestTryFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestUrlFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestUrlFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestUrlFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestUrlFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestWordStemFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestWordStemFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestWordStemFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestWordStemFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestZipFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestZipFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/TestZipWithFunction.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipWithFunction.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/TestZipWithFunction.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipWithFunction.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/date/TestExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/date/TestExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/date/TestExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/date/TestExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/time/TestExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/time/TestExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/time/TestOperators.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestOperators.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/time/TestOperators.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestOperators.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/time/TestTime.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestTime.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/time/TestTime.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestTime.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestAtTimeZone.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestAtTimeZone.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestAtTimeZone.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestAtTimeZone.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestDateTrunc.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestDateTrunc.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestDateTrunc.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestDateTrunc.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestExtract.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestExtract.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestExtract.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestExtract.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestOperators.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestOperators.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestOperators.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestOperators.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.out
diff --git
a/regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestTimestampWithTimeZone.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimestampWithTimeZone.out
similarity index 100%
rename from
regression-test/data/dialect_compatible/sql/presto/scalar/timetz/TestTimestampWithTimeZone.out
rename to
regression-test/data/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimestampWithTimeZone.out
diff --git
a/regression-test/data/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.out
b/regression-test/data/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.out
new file mode 100644
index 00000000000..35eb52d576f
Binary files /dev/null and
b/regression-test/data/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.out
differ
diff --git
a/regression-test/data/query_p0/sql_functions/string_functions/test_trim.out
b/regression-test/data/query_p0/sql_functions/string_functions/test_trim.out
new file mode 100644
index 00000000000..24b3deca22a
Binary files /dev/null and
b/regression-test/data/query_p0/sql_functions/string_functions/test_trim.out
differ
diff --git a/regression-test/suites/dialect_compatible/sql/clickhouse.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/clickhouse.sql
similarity index 100%
rename from regression-test/suites/dialect_compatible/sql/clickhouse.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/clickhouse.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/AbstractTestRegexpFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayCombinationsFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayContainsSequence.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayExceptFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFilterFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayHistogramFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayMatchFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayNgramsFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayReduceFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTransformFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestArrayTrimFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestBitwiseFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestBlockAndPositionNullConvention.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestConcatWsFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestCustomFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestCustomFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestCustomFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestCustomFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestDataSizeFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestDateTimeFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestIpAddressFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestIsNullAnnotation.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestJsonExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestJsonExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestJsonFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestJsonFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestJsonFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestLuhnCheckFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapFilterFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformKeysFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMapTransformValuesFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestMathFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMathFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestMathFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestMathFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestScalarParser.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestScalarParser.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestScalarParser.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestScalarParser.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestStringFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestStringFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestStringFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestStringFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestTryFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestTryFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestTryFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestTryFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestTypeOfFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestUrlFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestUrlFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestUrlFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestUrlFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestVarbinaryFunctions.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestWordStemFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestWordStemFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestWordStemFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestWordStemFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestZipFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestZipFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/TestZipWithFunction.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipWithFunction.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/TestZipWithFunction.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/TestZipWithFunction.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/date/TestExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/date/TestExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/date/TestExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/date/TestExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalDayTime.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/interval/TestIntervalYearMonth.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestOperators.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestOperators.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestOperators.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestOperators.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestTime.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestTime.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/time/TestTime.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/time/TestTime.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestDateTrunc.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestHumanReadableSeconds.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestOperators.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamp/TestTimestamp.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestAtTimeZone.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestDateTrunc.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestOperators.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timestamptz/TestTimestampWithTimeZone.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestExtract.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestExtract.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestExtract.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestExtract.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestOperators.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestOperators.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestOperators.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestOperators.sql
diff --git
a/regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.sql
b/regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.sql
similarity index 100%
rename from
regression-test/suites/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.sql
rename to
regression-test/suites/external_table_p0/dialect_compatible/sql/presto/scalar/timetz/TestTimeWithTimeZone.sql
diff --git
a/regression-test/suites/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.groovy
b/regression-test/suites/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.groovy
new file mode 100644
index 00000000000..4793786909f
--- /dev/null
+++
b/regression-test/suites/external_table_p0/dialect_compatible/sql/test_hive_view_rewrite.groovy
@@ -0,0 +1,48 @@
+// 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.
+
+suite("test_hive_view_rewrite",
"external_docker,hive,external_docker_hive,p0,external") {
+ String enabled = context.config.otherConfigs.get("enableHiveTest")
+ if (enabled == null || !enabled.equalsIgnoreCase("true")) {
+ logger.info("diable Hive test.")
+ return;
+ }
+
+ for (String hivePrefix : ["hive2"]) {
+ setHivePrefix(hivePrefix)
+ String catalog_name = "test_${hivePrefix}_view_rewrite"
+ String ex_db_name = "`default`"
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ String hms_port = context.config.otherConfigs.get(hivePrefix +
"HmsPort")
+ String hdfs_port = context.config.otherConfigs.get(hivePrefix +
"HdfsPort")
+
+ sql """drop catalog if exists ${catalog_name} """
+
+ sql """CREATE CATALOG ${catalog_name} PROPERTIES (
+ 'type'='hms',
+ 'hive.metastore.uris' = 'thrift://${externalEnvIp}:${hms_port}',
+ 'hadoop.username' = 'hive'
+ );"""
+
+ sql """set sql_dialect='hive';"""
+
+ order_qt_sql1 """ select * from
${catalog_name}.${ex_db_name}.department_view """
+
+ order_qt_sql2 """ select * from
${catalog_name}.${ex_db_name}.department_nesting_view """
+ }
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]