You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/12 05:42:12 UTC

[GitHub] [incubator-doris] morningman commented on a diff in pull request #10033: [feature-wip](multi-catalog) DataSource operation syntax

morningman commented on code in PR #10033:
URL: https://github.com/apache/incubator-doris/pull/10033#discussion_r895104883


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDatasourceStmt.java:
##########
@@ -0,0 +1,77 @@
+// 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.analysis;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.qe.ShowResultSetMetaData;
+
+/**
+ * Statement for show all datasource or desc the specific datasource.
+ */
+public class ShowDatasourceStmt extends ShowStmt {
+    private final String dsName;
+
+    public ShowDatasourceStmt(String dsName) {
+        this.dsName = dsName;
+    }
+
+    public ShowDatasourceStmt() {
+        this.dsName = null;
+    }
+
+    public String getDsName() {
+        return dsName;
+    }
+
+    @Override
+    public void analyze(Analyzer analyzer)  throws AnalysisException, UserException {
+        super.analyze(analyzer);
+    }
+
+    @Override
+    public String toSql() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("SHOW");
+        sb.append(" DATASOURCE");
+
+        if (dsName != null) {
+            sb.append(" ").append(dsName);
+        }
+
+        return sb.toString();
+    }
+
+    @Override
+    public String toString() {
+        return toSql();
+    }
+
+    @Override
+    public ShowResultSetMetaData getMetaData() {
+        ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder();

Review Comment:
   define a static final field for `ShowResultSetMetaData`



##########
fe/fe-common/src/main/java/org/apache/doris/common/FeMetaVersion.java:
##########
@@ -40,8 +40,10 @@ public final class FeMetaVersion {
     public static final int VERSION_109 = 109;
     // For routine load user info
     public static final int VERSION_110 = 110;
+    // for datasource
+    public static final int VERSION_111 = 111;
     // note: when increment meta version, should assign the latest version to VERSION_CURRENT
-    public static final int VERSION_CURRENT = VERSION_110;
+    public static final int VERSION_CURRENT = VERSION_111;

Review Comment:
   No need to update this version after rebase with #10005 



##########
fe/fe-core/src/main/cup/sql_parser.cup:
##########
@@ -1224,6 +1233,11 @@ create_stmt ::=
     {:
         RESULT = new CreateDbStmt(ifNotExists, db, null);
     :}
+    /* Datasource */
+    | KW_CREATE KW_EXTERNAL KW_DATASOURCE ident:ds opt_properties:properties
+    {:
+         RESULT = new CreateDatasourceStmt(ds, properties);
+    :}

Review Comment:
   And please add a config in `Config.java` like `enable_multi_catalog`, and default is `false`,
   to forbid this under-developement feature



##########
fe/fe-core/src/main/cup/sql_parser.cup:
##########
@@ -858,9 +858,18 @@ alter_stmt ::=
     {:
         RESULT = new AlterDatabaseRename(dbName, newDbName);
     :}
-    | KW_ALTER KW_DATABASE ident:dbName KW_SET KW_PROPERTIES LPAREN key_value_map:map RPAREN
+    | KW_ALTER KW_DATABASE ident:dsName KW_SET KW_PROPERTIES LPAREN key_value_map:map RPAREN

Review Comment:
   ```suggestion
       | KW_ALTER KW_DATABASE ident:dbName KW_SET KW_PROPERTIES LPAREN key_value_map:map RPAREN
   ```



##########
fe/fe-core/src/main/cup/sql_parser.cup:
##########
@@ -276,7 +276,7 @@ terminal String KW_ADD, KW_ADMIN, KW_AFTER, KW_AGGREGATE, KW_ALIAS, KW_ALL, KW_A
     KW_UNCOMMITTED, KW_UNBOUNDED, KW_UNION, KW_UNIQUE, KW_UNLOCK, KW_UNSIGNED, KW_USE, KW_USER, KW_USING, KW_UNINSTALL,
     KW_VALUE, KW_VALUES, KW_VARCHAR, KW_VARIABLES, KW_VERBOSE, KW_VIEW,
     KW_WARNINGS, KW_WEEK, KW_WHEN, KW_WHITELIST, KW_WHERE, KW_WITH, KW_WORK, KW_WRITE,
-    KW_YEAR;
+    KW_YEAR, KW_DATASOURCE;

Review Comment:
   As we discussed with @dujl before, we prefer to use keyword `catalog` in syntax, although the internal implements is also called `datasource`.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/DataSourceLog.java:
##########
@@ -0,0 +1,68 @@
+// 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;
+
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.persist.gson.GsonPostProcessable;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * A union metadata log for all the datasource operator include create,drop and alter.
+ */
+@NoArgsConstructor
+@Getter
+@Data
+public class DataSourceLog implements Writable, GsonPostProcessable {
+    @SerializedName(value = "dsName")
+    private String dsName;
+
+    @SerializedName(value = "props")
+    private Map<String, String> props;
+
+    @SerializedName(value = "newDsName")
+    private String newDsName;
+
+    @SerializedName(value = "newProps")
+    private Map<String, String> newProps;
+
+    @Override
+    public void write(DataOutput out) throws IOException {
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
+
+    @Override
+    public void gsonPostProcess() throws IOException {

Review Comment:
   No need override this if not use



##########
fe/fe-core/src/main/cup/sql_parser.cup:
##########
@@ -1224,6 +1233,11 @@ create_stmt ::=
     {:
         RESULT = new CreateDbStmt(ifNotExists, db, null);
     :}
+    /* Datasource */
+    | KW_CREATE KW_EXTERNAL KW_DATASOURCE ident:ds opt_properties:properties

Review Comment:
   Add `if exists` and `if not exists` for DROP and ADD operation



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org