Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-28 Thread via GitHub


LadyForest merged PR #24630:
URL: https://github.com/apache/flink/pull/24630


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-28 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2081366467

   @flinkbot run azure


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-25 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1580315151


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+properties.forEach((key, value) -> 
rows.add(Arrays.asList("option:" + key, value)));

Review Comment:
   done :)



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-25 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1580314751


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+properties.forEach((key, value) -> 
rows.add(Arrays.asList("option:" + key, value)));

Review Comment:
   mail thread: https://lists.apache.org/thread/tkgg1lv9hg8s3p44256nh5pl48wfwmtf



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1576399545


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+properties.forEach((key, value) -> 
rows.add(Arrays.asList("option:" + key, value)));

Review Comment:
   I have updated as the first output style, and will raise a discussion in dev 
mail. thanks for your suggesion~



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1576399545


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+properties.forEach((key, value) -> 
rows.add(Arrays.asList("option:" + key, value)));

Review Comment:
   I have updated as the second output style, and will raise a discussion in 
dev mail. thanks for your suggesion~



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1576399545


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+properties.forEach((key, value) -> 
rows.add(Arrays.asList("option:" + key, value)));

Review Comment:
   I have updated as the second output style, and will raise a discussion in 
dev mail.



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1576316717


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlOtherOperationConverterTest.java:
##
@@ -71,6 +72,41 @@ void testUseCatalog() {
 assertThat(operation.asSummaryString()).isEqualTo("USE CATALOG cat1");
 }
 
+@Test

Review Comment:
   excellent~



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


LadyForest commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1575805528


##
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/operations/SqlOtherOperationConverterTest.java:
##
@@ -71,6 +72,41 @@ void testUseCatalog() {
 assertThat(operation.asSummaryString()).isEqualTo("USE CATALOG cat1");
 }
 
+@Test

Review Comment:
   The test can be simplified as 
   
   ```java
   @CsvSource({"true,true", "true,false", "false,true", "false,false"})
   @ParameterizedTest
   void testDescribeCatalog(boolean abbr, boolean extended) {
   final String catalogName = "cat1";
   final String sql =
   String.format(
   "%s CATALOG %s %s",
   abbr ? "DESC" : "DESCRIBE", extended ? "EXTENDED" : 
"", catalogName);
   Operation operation = parse(sql);
   assertThat(operation)
   .isInstanceOf(DescribeCatalogOperation.class)
   .asInstanceOf(type(DescribeCatalogOperation.class))
   .extracting(
   DescribeCatalogOperation::getCatalogName,
   DescribeCatalogOperation::isExtended,
   DescribeCatalogOperation::asSummaryString)
   .containsExactly(
   catalogName,
   extended,
   String.format(
   "DESCRIBE CATALOG: (identifier: [%s], 
isExtended: [%b])",
   catalogName, extended));
   }
   ```



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-23 Thread via GitHub


LadyForest commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1575595115


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("name", catalogName),
+Arrays.asList(
+"type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("comment", "") // TODO: retain 
for future needs

Review Comment:
   Nit: add JIRA task id



##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,98 @@
+/*
+ * 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.flink.table.operations;
+
+import 

Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2065632965

   @LadyForest Hi, I have updated as you said, besides, rebased on the latest 
master branch and CI passed, PTAL, thanks :)


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2065504494

   @flinkbot run azure


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2064501044

   @flinkbot run azure


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2064332698

   @flinkbot run azure


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2063913126

   @LadyForest Hi, I have updated as you said and CI passed, PTAL, thanks :)


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1570466913


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("Name", catalogName),
+Arrays.asList(
+"Type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("Comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+rows.add(Arrays.asList("Properties", 
convertPropertiesToString(properties)));
+}
+
+return buildTableResult(
+Arrays.asList("catalog_description_item", 
"catalog_description_value")

Review Comment:
   reasonable enough, done :)



-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


liyubin117 commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1570448160


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("Name", catalogName),
+Arrays.asList(
+"Type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("Comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+rows.add(Arrays.asList("Properties", 
convertPropertiesToString(properties)));
+}
+
+return buildTableResult(
+Arrays.asList("catalog_description_item", 
"catalog_description_value")
+.toArray(new String[0]),
+Arrays.asList(DataTypes.STRING(), 
DataTypes.STRING()).toArray(new DataType[0]),
+rows.stream().map(List::toArray).toArray(Object[][]::new));
+}
+
+private String convertPropertiesToString(Map map) {
+StringBuilder stringBuilder = new StringBuilder();
+for (Map.Entry entry : map.entrySet()) {
+stringBuilder.append(
+String.format(
+"('%s','%s'), ",
+EncodingUtils.escapeSingleQuotes(entry.getKey()),
+
EncodingUtils.escapeSingleQuotes(entry.getValue(;
+}
+// remove the last unnecessary comma and space
+ 

Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


LadyForest commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1570355268


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("Name", catalogName),
+Arrays.asList(
+"Type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("Comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+rows.add(Arrays.asList("Properties", 
convertPropertiesToString(properties)));
+}
+
+return buildTableResult(
+Arrays.asList("catalog_description_item", 
"catalog_description_value")
+.toArray(new String[0]),
+Arrays.asList(DataTypes.STRING(), 
DataTypes.STRING()).toArray(new DataType[0]),
+rows.stream().map(List::toArray).toArray(Object[][]::new));
+}
+
+private String convertPropertiesToString(Map map) {
+StringBuilder stringBuilder = new StringBuilder();
+for (Map.Entry entry : map.entrySet()) {
+stringBuilder.append(
+String.format(
+"('%s','%s'), ",
+EncodingUtils.escapeSingleQuotes(entry.getKey()),
+
EncodingUtils.escapeSingleQuotes(entry.getValue(;
+}
+// remove the last unnecessary comma and space
+ 

Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


LadyForest commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1570354008


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("Name", catalogName),
+Arrays.asList(
+"Type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("Comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+rows.add(Arrays.asList("Properties", 
convertPropertiesToString(properties)));
+}
+
+return buildTableResult(
+Arrays.asList("catalog_description_item", 
"catalog_description_value")
+.toArray(new String[0]),
+Arrays.asList(DataTypes.STRING(), 
DataTypes.STRING()).toArray(new DataType[0]),
+rows.stream().map(List::toArray).toArray(Object[][]::new));
+}
+
+private String convertPropertiesToString(Map map) {
+StringBuilder stringBuilder = new StringBuilder();
+for (Map.Entry entry : map.entrySet()) {
+stringBuilder.append(
+String.format(
+"('%s','%s'), ",
+EncodingUtils.escapeSingleQuotes(entry.getKey()),
+
EncodingUtils.escapeSingleQuotes(entry.getValue(;
+}
+// remove the last unnecessary comma and space
+ 

Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-18 Thread via GitHub


LadyForest commented on code in PR #24630:
URL: https://github.com/apache/flink/pull/24630#discussion_r1570354008


##
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/operations/DescribeCatalogOperation.java:
##
@@ -0,0 +1,114 @@
+/*
+ * 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.flink.table.operations;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.DataTypes;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.api.internal.TableResultInternal;
+import org.apache.flink.table.catalog.CatalogDescriptor;
+import org.apache.flink.table.catalog.CommonCatalogOptions;
+import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static 
org.apache.flink.table.api.internal.TableResultUtils.buildTableResult;
+
+/** Operation to describe a DESCRIBE CATALOG catalog_name statement. */
+@Internal
+public class DescribeCatalogOperation implements Operation, 
ExecutableOperation {
+
+private final String catalogName;
+private final boolean isExtended;
+
+public DescribeCatalogOperation(String catalogName, boolean isExtended) {
+this.catalogName = catalogName;
+this.isExtended = isExtended;
+}
+
+public String getCatalogName() {
+return catalogName;
+}
+
+public boolean isExtended() {
+return isExtended;
+}
+
+@Override
+public String asSummaryString() {
+Map params = new LinkedHashMap<>();
+params.put("identifier", catalogName);
+params.put("isExtended", isExtended);
+return OperationUtils.formatWithChildren(
+"DESCRIBE CATALOG", params, Collections.emptyList(), 
Operation::asSummaryString);
+}
+
+@Override
+public TableResultInternal execute(Context ctx) {
+CatalogDescriptor catalogDescriptor =
+ctx.getCatalogManager()
+.getCatalogDescriptor(catalogName)
+.orElseThrow(
+() ->
+new ValidationException(
+String.format(
+"Cannot obtain 
metadata information from Catalog %s.",
+catalogName)));
+Map properties = 
catalogDescriptor.getConfiguration().toMap();
+List> rows =
+new ArrayList<>(
+Arrays.asList(
+Arrays.asList("Name", catalogName),
+Arrays.asList(
+"Type",
+properties.getOrDefault(
+
CommonCatalogOptions.CATALOG_TYPE.key(), "")),
+Arrays.asList("Comment", "") // TODO: retain 
for future needs
+));
+if (isExtended) {
+rows.add(Arrays.asList("Properties", 
convertPropertiesToString(properties)));
+}
+
+return buildTableResult(
+Arrays.asList("catalog_description_item", 
"catalog_description_value")
+.toArray(new String[0]),
+Arrays.asList(DataTypes.STRING(), 
DataTypes.STRING()).toArray(new DataType[0]),
+rows.stream().map(List::toArray).toArray(Object[][]::new));
+}
+
+private String convertPropertiesToString(Map map) {
+StringBuilder stringBuilder = new StringBuilder();
+for (Map.Entry entry : map.entrySet()) {
+stringBuilder.append(
+String.format(
+"('%s','%s'), ",
+EncodingUtils.escapeSingleQuotes(entry.getKey()),
+
EncodingUtils.escapeSingleQuotes(entry.getValue(;
+}
+// remove the last unnecessary comma and space
+ 

Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-17 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2062885502

   @LadyForest Hi, Could you please take a review? thanks!


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-07 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2041527525

   @LadyForest Hi, CI passed now, Looking forward your review, Thanks very much 
:)


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-07 Thread via GitHub


liyubin117 commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2041411609

   @flinkbot run azure


-- 
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: issues-unsubscr...@flink.apache.org

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



Re: [PR] [FLINK-34915][table] Complete `DESCRIBE CATALOG` syntax [flink]

2024-04-07 Thread via GitHub


flinkbot commented on PR #24630:
URL: https://github.com/apache/flink/pull/24630#issuecomment-2041394595

   
   ## CI report:
   
   * a1146244ce8a490c2ca1557f4c2410b59effb333 UNKNOWN
   
   
   Bot commands
 The @flinkbot bot supports the following commands:
   
- `@flinkbot run azure` re-run the last Azure build
   


-- 
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: issues-unsubscr...@flink.apache.org

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