This is an automated email from the ASF dual-hosted git repository. zykkk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 54a7dbeb4d [Refactor](External) Move Common ODBC Methods to JDBC Class and Add Default config to Disable ODBC Creation (#20566) 54a7dbeb4d is described below commit 54a7dbeb4ddd68d8e15d8b6e12d050bc7af24730 Author: zy-kkk <zhongy...@gmail.com> AuthorDate: Tue Jun 13 14:29:04 2023 +0800 [Refactor](External) Move Common ODBC Methods to JDBC Class and Add Default config to Disable ODBC Creation (#20566) This PR addresses the refactoring of common methods that were originally located within the ODBC classes, but were used by the JDBC classes. These methods have now been moved to the JDBC classes to improve code readability and maintainability. In addition, we have disabled the creation of ODBC external tables by default. However, this will not affect the existing usage of ODBC. You can still enable the ODBC external tables through the enable_odbc_table setting. Please be aware that we plan to completely remove the ODBC external tables in future versions, so we recommend using the JDBC Catalog as a priority. --- .../main/java/org/apache/doris/common/Config.java | 9 +++ .../apache/doris/analysis/CreateResourceStmt.java | 5 ++ .../org/apache/doris/analysis/CreateTableStmt.java | 4 ++ .../java/org/apache/doris/catalog/JdbcTable.java | 72 +++++++++++++++++++++- .../java/org/apache/doris/catalog/OdbcTable.java | 70 --------------------- .../org/apache/doris/planner/JdbcScanNode.java | 64 +++++++++++++++++-- .../org/apache/doris/planner/JdbcTableSink.java | 3 +- .../org/apache/doris/planner/OdbcScanNode.java | 65 ++----------------- .../org/apache/doris/planner/OdbcTableSink.java | 3 +- .../java/org/apache/doris/alter/AlterTest.java | 1 + .../doris/analysis/CreateResourceStmtTest.java | 2 + .../org/apache/doris/catalog/EnvOperationTest.java | 2 + .../doris/catalog/OdbcCatalogResourceTest.java | 2 + .../apache/doris/utframe/TestWithFeService.java | 1 + 14 files changed, 164 insertions(+), 139 deletions(-) diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java index 055291a2d7..dc3f9def3d 100644 --- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java +++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java @@ -1766,6 +1766,15 @@ public class Config extends ConfigBase { @ConfField(mutable = false, expType = ExperimentalType.EXPERIMENTAL) public static boolean enable_fqdn_mode = false; + /** + * enable use odbc table + */ + @ConfField(mutable = true, masterOnly = true, description = { + "是否开启 ODBC 外表功能,默认关闭,ODBC 外表是淘汰的功能,请使用 JDBC Catalog", + "Whether to enable the ODBC appearance function, it is disabled by default," + + " and the ODBC appearance is an obsolete feature. Please use the JDBC Catalog"}) + public static boolean enable_odbc_table = false; + /** * This is used whether to push down function to MYSQL in external Table with query sql * like odbc, jdbc for mysql table diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateResourceStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateResourceStmt.java index d13e8e76b2..6e529be7a9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateResourceStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateResourceStmt.java @@ -20,6 +20,7 @@ package org.apache.doris.analysis; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.Resource.ResourceType; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; import org.apache.doris.common.FeNameFormat; @@ -93,6 +94,10 @@ public class CreateResourceStmt extends DdlStmt { if (resourceType == ResourceType.SPARK && !isExternal) { throw new AnalysisException("Spark is external resource"); } + if (resourceType == ResourceType.ODBC_CATALOG && !Config.enable_odbc_table) { + throw new AnalysisException("ODBC table is deprecated, use JDBC instead. Or you can set " + + "`enable_odbc_table=true` in fe.conf to enable ODBC again."); + } } @Override diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java index 2eae045e35..5e511176e0 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java @@ -626,6 +626,10 @@ public class CreateTableStmt extends DdlStmt { if (engineName.equals("mysql") || engineName.equals("odbc") || engineName.equals("broker") || engineName.equals("elasticsearch") || engineName.equals("hive") || engineName.equals("iceberg") || engineName.equals("hudi") || engineName.equals("jdbc")) { + if (engineName.equals("odbc") && !Config.enable_odbc_table) { + throw new AnalysisException("ODBC table is deprecated, use JDBC instead. Or you can set " + + "`enable_odbc_table=true` in fe.conf to enable ODBC again."); + } if (!isExternal) { // this is for compatibility isExternal = true; diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java index 432cfd0aae..e330702e71 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/JdbcTable.java @@ -99,7 +99,7 @@ public class JdbcTable extends Table { public String getInsertSql() { StringBuilder sb = new StringBuilder("INSERT INTO "); - sb.append(OdbcTable.databaseProperName(TABLE_TYPE_MAP.get(getTableTypeName()), getExternalTableName())); + sb.append(databaseProperName(TABLE_TYPE_MAP.get(getTableTypeName()), getExternalTableName())); sb.append(" VALUES ("); for (int i = 0; i < getFullSchema().size(); ++i) { if (i != 0) { @@ -313,4 +313,74 @@ public class JdbcTable extends Table { } } } + + /** + * Formats the provided name (for example, a database, table, or schema name) according to the specified parameters. + * + * @param name The name to be formatted. + * @param wrapStart The character(s) to be added at the start of each name component. + * @param wrapEnd The character(s) to be added at the end of each name component. + * @param toUpperCase If true, convert the name to upper case. + * @param toLowerCase If true, convert the name to lower case. + * <p> + * Note: If both toUpperCase and toLowerCase are true, the name will ultimately be converted to lower case. + * <p> + * The name is expected to be in the format of 'schemaName.tableName'. If there is no '.', + * the function will treat the entire string as one name component. + * If there is a '.', the function will treat the string before the first '.' as the schema name + * and the string after the '.' as the table name. + * + * @return The formatted name. + */ + public static String formatName(String name, String wrapStart, String wrapEnd, boolean toUpperCase, + boolean toLowerCase) { + int index = name.indexOf("."); + if (index == -1) { // No dot in the name + String newName = toUpperCase ? name.toUpperCase() : name; + newName = toLowerCase ? newName.toLowerCase() : newName; + return wrapStart + newName + wrapEnd; + } else { + String schemaName = toUpperCase ? name.substring(0, index).toUpperCase() : name.substring(0, index); + schemaName = toLowerCase ? schemaName.toLowerCase() : schemaName; + String tableName = toUpperCase ? name.substring(index + 1).toUpperCase() : name.substring(index + 1); + tableName = toLowerCase ? tableName.toLowerCase() : tableName; + return wrapStart + schemaName + wrapEnd + "." + wrapStart + tableName + wrapEnd; + } + } + + /** + * Formats a database name according to the database type. + * + * Rules: + * - MYSQL, OCEANBASE: Wrap with backticks (`), case unchanged. Example: mySchema.myTable -> `mySchema.myTable` + * - SQLSERVER: Wrap with square brackets ([]), case unchanged. Example: mySchema.myTable -> [mySchema].[myTable] + * - POSTGRESQL, CLICKHOUSE, TRINO, OCEANBASE_ORACLE, SAP_HANA: Wrap with double quotes ("), case unchanged. + * Example: mySchema.myTable -> "mySchema"."myTable" + * - ORACLE: Wrap with double quotes ("), convert to upper case. Example: mySchema.myTable -> "MYSCHEMA"."MYTABLE" + * For other types, the name is returned as is. + * + * @param tableType The database type. + * @param name The name to be formatted, expected in 'schemaName.tableName' format. If no '.', treats entire string + * as one name component. If '.', treats string before first '.' as schema name and after as table name. + * @return The formatted name. + */ + public static String databaseProperName(TOdbcTableType tableType, String name) { + switch (tableType) { + case MYSQL: + case OCEANBASE: + return formatName(name, "`", "`", false, false); + case SQLSERVER: + return formatName(name, "[", "]", false, false); + case POSTGRESQL: + case CLICKHOUSE: + case TRINO: + case OCEANBASE_ORACLE: + case SAP_HANA: + return formatName(name, "\"", "\"", false, false); + case ORACLE: + return formatName(name, "\"", "\"", true, false); + default: + return name; + } + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java index cab37a1ecf..6cd194b1eb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OdbcTable.java @@ -71,76 +71,6 @@ public class OdbcTable extends Table { TABLE_TYPE_MAP = Collections.unmodifiableMap(tempMap); } - /** - * Formats the provided name (for example, a database, table, or schema name) according to the specified parameters. - * - * @param name The name to be formatted. - * @param wrapStart The character(s) to be added at the start of each name component. - * @param wrapEnd The character(s) to be added at the end of each name component. - * @param toUpperCase If true, convert the name to upper case. - * @param toLowerCase If true, convert the name to lower case. - * <p> - * Note: If both toUpperCase and toLowerCase are true, the name will ultimately be converted to lower case. - * <p> - * The name is expected to be in the format of 'schemaName.tableName'. If there is no '.', - * the function will treat the entire string as one name component. - * If there is a '.', the function will treat the string before the first '.' as the schema name - * and the string after the '.' as the table name. - * - * @return The formatted name. - */ - public static String formatName(String name, String wrapStart, String wrapEnd, boolean toUpperCase, - boolean toLowerCase) { - int index = name.indexOf("."); - if (index == -1) { // No dot in the name - String newName = toUpperCase ? name.toUpperCase() : name; - newName = toLowerCase ? newName.toLowerCase() : newName; - return wrapStart + newName + wrapEnd; - } else { - String schemaName = toUpperCase ? name.substring(0, index).toUpperCase() : name.substring(0, index); - schemaName = toLowerCase ? schemaName.toLowerCase() : schemaName; - String tableName = toUpperCase ? name.substring(index + 1).toUpperCase() : name.substring(index + 1); - tableName = toLowerCase ? tableName.toLowerCase() : tableName; - return wrapStart + schemaName + wrapEnd + "." + wrapStart + tableName + wrapEnd; - } - } - - /** - * Formats a database name according to the database type. - * - * Rules: - * - MYSQL, OCEANBASE: Wrap with backticks (`), case unchanged. Example: mySchema.myTable -> `mySchema.myTable` - * - SQLSERVER: Wrap with square brackets ([]), case unchanged. Example: mySchema.myTable -> [mySchema].[myTable] - * - POSTGRESQL, CLICKHOUSE, TRINO, OCEANBASE_ORACLE, SAP_HANA: Wrap with double quotes ("), case unchanged. - * Example: mySchema.myTable -> "mySchema"."myTable" - * - ORACLE: Wrap with double quotes ("), convert to upper case. Example: mySchema.myTable -> "MYSCHEMA"."MYTABLE" - * For other types, the name is returned as is. - * - * @param tableType The database type. - * @param name The name to be formatted, expected in 'schemaName.tableName' format. If no '.', treats entire string - * as one name component. If '.', treats string before first '.' as schema name and after as table name. - * @return The formatted name. - */ - public static String databaseProperName(TOdbcTableType tableType, String name) { - switch (tableType) { - case MYSQL: - case OCEANBASE: - return formatName(name, "`", "`", false, false); - case SQLSERVER: - return formatName(name, "[", "]", false, false); - case POSTGRESQL: - case CLICKHOUSE: - case TRINO: - case OCEANBASE_ORACLE: - case SAP_HANA: - return formatName(name, "\"", "\"", false, false); - case ORACLE: - return formatName(name, "\"", "\"", true, false); - default: - return name; - } - } - private String odbcCatalogResourceName; private String host; private String port; diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcScanNode.java index 34bc96255a..8a7de98505 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcScanNode.java @@ -18,6 +18,8 @@ package org.apache.doris.planner; import org.apache.doris.analysis.Analyzer; +import org.apache.doris.analysis.BinaryPredicate; +import org.apache.doris.analysis.DateLiteral; import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.ExprSubstitutionMap; import org.apache.doris.analysis.FunctionCallExpr; @@ -28,9 +30,10 @@ import org.apache.doris.analysis.TupleDescriptor; import org.apache.doris.catalog.Column; import org.apache.doris.catalog.Env; import org.apache.doris.catalog.JdbcTable; -import org.apache.doris.catalog.OdbcTable; +import org.apache.doris.catalog.Type; import org.apache.doris.catalog.external.JdbcExternalTable; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.UserException; import org.apache.doris.nereids.glue.translator.PlanTranslatorContext; import org.apache.doris.planner.external.ExternalScanNode; @@ -73,7 +76,7 @@ public class JdbcScanNode extends ExternalScanNode { tbl = (JdbcTable) (desc.getTable()); } jdbcType = tbl.getJdbcTableType(); - tableName = OdbcTable.databaseProperName(jdbcType, tbl.getJdbcTable()); + tableName = JdbcTable.databaseProperName(jdbcType, tbl.getJdbcTable()); } @Override @@ -123,14 +126,14 @@ public class JdbcScanNode extends ExternalScanNode { for (SlotRef slotRef : slotRefs) { SlotRef slotRef1 = (SlotRef) slotRef.clone(); slotRef1.setTblName(null); - slotRef1.setLabel(OdbcTable.databaseProperName(jdbcType, slotRef1.getColumnName())); + slotRef1.setLabel(JdbcTable.databaseProperName(jdbcType, slotRef1.getColumnName())); sMap.put(slotRef, slotRef1); } ArrayList<Expr> conjunctsList = Expr.cloneList(conjuncts, sMap); for (Expr p : conjunctsList) { - if (OdbcScanNode.shouldPushDownConjunct(jdbcType, p)) { - String filter = OdbcScanNode.conjunctExprToString(jdbcType, p); + if (shouldPushDownConjunct(jdbcType, p)) { + String filter = conjunctExprToString(jdbcType, p); filters.add(filter); conjuncts.remove(p); } @@ -144,7 +147,7 @@ public class JdbcScanNode extends ExternalScanNode { continue; } Column col = slot.getColumn(); - columns.add(OdbcTable.databaseProperName(jdbcType, col.getName())); + columns.add(JdbcTable.databaseProperName(jdbcType, col.getName())); } if (0 == columns.size()) { columns.add("*"); @@ -270,4 +273,53 @@ public class JdbcScanNode extends ExternalScanNode { Env.getCurrentEnv().getCurrentCatalog().getDbOrAnalysisException(tbl.getQualifiedDbName()).getId(), tbl.getId(), -1L); } + + // Now some database have different function call like doris, now doris do not + // push down the function call except MYSQL + public static boolean shouldPushDownConjunct(TOdbcTableType tableType, Expr expr) { + if (!tableType.equals(TOdbcTableType.MYSQL)) { + List<FunctionCallExpr> fnExprList = Lists.newArrayList(); + expr.collect(FunctionCallExpr.class, fnExprList); + if (!fnExprList.isEmpty()) { + return false; + } + } + return Config.enable_func_pushdown; + } + + public static String conjunctExprToString(TOdbcTableType tableType, Expr expr) { + if (tableType.equals(TOdbcTableType.ORACLE) && expr.contains(DateLiteral.class) + && (expr instanceof BinaryPredicate)) { + ArrayList<Expr> children = expr.getChildren(); + // k1 OP '2022-12-10 20:55:59' changTo ---> k1 OP to_date('{}','yyyy-mm-dd hh24:mi:ss') + // oracle datetime push down is different: https://github.com/apache/doris/discussions/15069 + if (children.get(1).isConstant() && (children.get(1).getType().equals(Type.DATETIME) || children + .get(1).getType().equals(Type.DATETIMEV2))) { + String filter = children.get(0).toSql(); + filter += ((BinaryPredicate) expr).getOp().toString(); + filter += "to_date('" + children.get(1).getStringValue() + "','yyyy-mm-dd hh24:mi:ss')"; + return filter; + } + } + if (tableType.equals(TOdbcTableType.TRINO) && expr.contains(DateLiteral.class) + && (expr instanceof BinaryPredicate)) { + ArrayList<Expr> children = expr.getChildren(); + if (children.get(1).isConstant() && (children.get(1).getType().isDate()) || children + .get(1).getType().isDateV2()) { + String filter = children.get(0).toSql(); + filter += ((BinaryPredicate) expr).getOp().toString(); + filter += "date '" + children.get(1).getStringValue() + "'"; + return filter; + } + if (children.get(1).isConstant() && (children.get(1).getType().isDatetime() || children + .get(1).getType().isDatetimeV2())) { + String filter = children.get(0).toSql(); + filter += ((BinaryPredicate) expr).getOp().toString(); + filter += "timestamp '" + children.get(1).getStringValue() + "'"; + return filter; + } + } + + return expr.toMySql(); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcTableSink.java b/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcTableSink.java index 73b981b19a..1ab94d274a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcTableSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/JdbcTableSink.java @@ -18,7 +18,6 @@ package org.apache.doris.planner; import org.apache.doris.catalog.JdbcTable; -import org.apache.doris.catalog.OdbcTable; import org.apache.doris.qe.ConnectContext; import org.apache.doris.thrift.TDataSink; import org.apache.doris.thrift.TDataSinkType; @@ -49,7 +48,7 @@ public class JdbcTableSink extends DataSink { public JdbcTableSink(JdbcTable jdbcTable) { resourceName = jdbcTable.getResourceName(); jdbcType = jdbcTable.getJdbcTableType(); - externalTableName = OdbcTable.databaseProperName(jdbcType, jdbcTable.getExternalTableName()); + externalTableName = JdbcTable.databaseProperName(jdbcType, jdbcTable.getExternalTableName()); useTransaction = ConnectContext.get().getSessionVariable().isEnableOdbcTransaction(); jdbcUrl = jdbcTable.getJdbcUrl(); jdbcUser = jdbcTable.getJdbcUser(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java index 3439987f16..07b2d3775b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java @@ -18,20 +18,16 @@ package org.apache.doris.planner; import org.apache.doris.analysis.Analyzer; -import org.apache.doris.analysis.BinaryPredicate; -import org.apache.doris.analysis.DateLiteral; import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.ExprSubstitutionMap; -import org.apache.doris.analysis.FunctionCallExpr; import org.apache.doris.analysis.SlotDescriptor; import org.apache.doris.analysis.SlotRef; import org.apache.doris.analysis.TupleDescriptor; import org.apache.doris.catalog.Column; import org.apache.doris.catalog.Env; +import org.apache.doris.catalog.JdbcTable; import org.apache.doris.catalog.OdbcTable; -import org.apache.doris.catalog.Type; import org.apache.doris.common.AnalysisException; -import org.apache.doris.common.Config; import org.apache.doris.common.UserException; import org.apache.doris.planner.external.ExternalScanNode; import org.apache.doris.statistics.StatisticalType; @@ -58,55 +54,6 @@ import java.util.List; public class OdbcScanNode extends ExternalScanNode { private static final Logger LOG = LogManager.getLogger(OdbcScanNode.class); - // Now some database have different function call like doris, now doris do not - // push down the function call except MYSQL - public static boolean shouldPushDownConjunct(TOdbcTableType tableType, Expr expr) { - if (!tableType.equals(TOdbcTableType.MYSQL)) { - List<FunctionCallExpr> fnExprList = Lists.newArrayList(); - expr.collect(FunctionCallExpr.class, fnExprList); - if (!fnExprList.isEmpty()) { - return false; - } - } - return Config.enable_func_pushdown; - } - - public static String conjunctExprToString(TOdbcTableType tableType, Expr expr) { - if (tableType.equals(TOdbcTableType.ORACLE) && expr.contains(DateLiteral.class) - && (expr instanceof BinaryPredicate)) { - ArrayList<Expr> children = expr.getChildren(); - // k1 OP '2022-12-10 20:55:59' changTo ---> k1 OP to_date('{}','yyyy-mm-dd hh24:mi:ss') - // oracle datetime push down is different: https://github.com/apache/doris/discussions/15069 - if (children.get(1).isConstant() && (children.get(1).getType().equals(Type.DATETIME) || children - .get(1).getType().equals(Type.DATETIMEV2))) { - String filter = children.get(0).toSql(); - filter += ((BinaryPredicate) expr).getOp().toString(); - filter += "to_date('" + children.get(1).getStringValue() + "','yyyy-mm-dd hh24:mi:ss')"; - return filter; - } - } - if (tableType.equals(TOdbcTableType.TRINO) && expr.contains(DateLiteral.class) - && (expr instanceof BinaryPredicate)) { - ArrayList<Expr> children = expr.getChildren(); - if (children.get(1).isConstant() && (children.get(1).getType().isDate()) || children - .get(1).getType().isDateV2()) { - String filter = children.get(0).toSql(); - filter += ((BinaryPredicate) expr).getOp().toString(); - filter += "date '" + children.get(1).getStringValue() + "'"; - return filter; - } - if (children.get(1).isConstant() && (children.get(1).getType().isDatetime() || children - .get(1).getType().isDatetimeV2())) { - String filter = children.get(0).toSql(); - filter += ((BinaryPredicate) expr).getOp().toString(); - filter += "timestamp '" + children.get(1).getStringValue() + "'"; - return filter; - } - } - - return expr.toMySql(); - } - private final List<String> columns = new ArrayList<String>(); private final List<String> filters = new ArrayList<String>(); private String tblName; @@ -122,7 +69,7 @@ public class OdbcScanNode extends ExternalScanNode { super(id, desc, "SCAN ODBC", StatisticalType.ODBC_SCAN_NODE, false); connectString = tbl.getConnectString(); odbcType = tbl.getOdbcTableType(); - tblName = OdbcTable.databaseProperName(odbcType, tbl.getOdbcTableName()); + tblName = JdbcTable.databaseProperName(odbcType, tbl.getOdbcTableName()); this.tbl = tbl; } @@ -202,7 +149,7 @@ public class OdbcScanNode extends ExternalScanNode { continue; } Column col = slot.getColumn(); - columns.add(OdbcTable.databaseProperName(odbcType, col.getName())); + columns.add(JdbcTable.databaseProperName(odbcType, col.getName())); } // this happens when count(*) if (0 == columns.size()) { @@ -222,13 +169,13 @@ public class OdbcScanNode extends ExternalScanNode { for (SlotRef slotRef : slotRefs) { SlotRef tmpRef = (SlotRef) slotRef.clone(); tmpRef.setTblName(null); - tmpRef.setLabel(OdbcTable.databaseProperName(odbcType, tmpRef.getColumnName())); + tmpRef.setLabel(JdbcTable.databaseProperName(odbcType, tmpRef.getColumnName())); sMap.put(slotRef, tmpRef); } ArrayList<Expr> odbcConjuncts = Expr.cloneList(conjuncts, sMap); for (Expr p : odbcConjuncts) { - if (shouldPushDownConjunct(odbcType, p)) { - String filter = conjunctExprToString(odbcType, p); + if (JdbcScanNode.shouldPushDownConjunct(odbcType, p)) { + String filter = JdbcScanNode.conjunctExprToString(odbcType, p); filters.add(filter); conjuncts.remove(p); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcTableSink.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcTableSink.java index 68df73c63e..0fbe85ea32 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcTableSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcTableSink.java @@ -17,6 +17,7 @@ package org.apache.doris.planner; +import org.apache.doris.catalog.JdbcTable; import org.apache.doris.catalog.OdbcTable; import org.apache.doris.qe.ConnectContext; import org.apache.doris.thrift.TDataSink; @@ -36,7 +37,7 @@ public class OdbcTableSink extends DataSink { connectString = odbcTable.getConnectString(); originTblName = odbcTable.getName(); odbcType = odbcTable.getOdbcTableType(); - tblName = odbcTable.databaseProperName(odbcType, odbcTable.getOdbcTableName()); + tblName = JdbcTable.databaseProperName(odbcType, odbcTable.getOdbcTableName()); useTransaction = ConnectContext.get().getSessionVariable().isEnableOdbcTransaction(); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java index e182ab2a9b..d18f5a57f8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterTest.java @@ -184,6 +184,7 @@ public class AlterTest { } private static void createTable(String sql) throws Exception { + Config.enable_odbc_table = true; CreateTableStmt createTableStmt = (CreateTableStmt) UtFrameUtils.parseAndAnalyzeStmt(sql, connectContext); Env.getCurrentEnv().createTable(createTableStmt); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateResourceStmtTest.java b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateResourceStmtTest.java index d7291f477b..78defde017 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateResourceStmtTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateResourceStmtTest.java @@ -21,6 +21,7 @@ import org.apache.doris.catalog.Env; import org.apache.doris.catalog.Resource; import org.apache.doris.catalog.Resource.ResourceType; import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; import org.apache.doris.common.UserException; import org.apache.doris.mysql.privilege.AccessControllerManager; import org.apache.doris.mysql.privilege.PrivPredicate; @@ -73,6 +74,7 @@ public class CreateResourceStmtTest { properties = Maps.newHashMap(); properties.put("type", "odbc_catalog"); stmt = new CreateResourceStmt(true, false, resourceName2, properties); + Config.enable_odbc_table = true; stmt.analyze(analyzer); Assert.assertEquals(resourceName2, stmt.getResourceName()); Assert.assertEquals(Resource.ResourceType.ODBC_CATALOG, stmt.getResourceType()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/EnvOperationTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/EnvOperationTest.java index a4a8b9e59f..d9afb49eb2 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/EnvOperationTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/EnvOperationTest.java @@ -23,6 +23,7 @@ import org.apache.doris.analysis.AlterTableStmt; import org.apache.doris.analysis.CreateDbStmt; import org.apache.doris.analysis.CreateResourceStmt; import org.apache.doris.analysis.CreateTableStmt; +import org.apache.doris.common.Config; import org.apache.doris.common.DdlException; import org.apache.doris.common.FeConstants; import org.apache.doris.qe.ConnectContext; @@ -100,6 +101,7 @@ public class EnvOperationTest { } private static void createResource(String sql) throws Exception { + Config.enable_odbc_table = true; CreateResourceStmt createResourceStmt = (CreateResourceStmt) UtFrameUtils.parseAndAnalyzeStmt(sql, connectContext); Env.getCurrentEnv().getResourceMgr().createResource(createResourceStmt); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/OdbcCatalogResourceTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/OdbcCatalogResourceTest.java index 32a43e5cd9..d2ecea5145 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/catalog/OdbcCatalogResourceTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/OdbcCatalogResourceTest.java @@ -20,6 +20,7 @@ package org.apache.doris.catalog; import org.apache.doris.analysis.AccessTestUtil; import org.apache.doris.analysis.Analyzer; import org.apache.doris.analysis.CreateResourceStmt; +import org.apache.doris.common.Config; import org.apache.doris.common.FeMetaVersion; import org.apache.doris.common.UserException; import org.apache.doris.common.proc.BaseProcResult; @@ -86,6 +87,7 @@ public class OdbcCatalogResourceTest { // host: 127.0.0.1, port: 7777, without driver and odbc_type CreateResourceStmt stmt = new CreateResourceStmt(true, false, name, properties); + Config.enable_odbc_table = true; stmt.analyze(analyzer); OdbcCatalogResource resource = (OdbcCatalogResource) Resource.fromStmt(stmt); Assert.assertEquals(name, resource.getName()); diff --git a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java index 1a0d3d5c4f..ac2fe5978d 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java +++ b/fe/fe-core/src/test/java/org/apache/doris/utframe/TestWithFeService.java @@ -528,6 +528,7 @@ public abstract class TestWithFeService { public void createTable(String sql) throws Exception { try { + Config.enable_odbc_table = true; createTables(sql); } catch (ConcurrentModificationException e) { e.printStackTrace(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org