You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/20 19:27:21 UTC

[GitHub] [arrow] jcralmeida commented on a change in pull request #11999: [JAVA] Add missing metadata on Arrow schemas returned by Flight SQL

jcralmeida commented on a change in pull request #11999:
URL: https://github.com/apache/arrow/pull/11999#discussion_r772615930



##########
File path: java/flight/flight-sql/src/main/java/org/apache/arrow/flight/sql/FlightSqlColumnMetadata.java
##########
@@ -0,0 +1,295 @@
+/*
+ * 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.arrow.flight.sql;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Metadata for a column in a Flight SQL query.
+ *
+ * This can be used with FlightSqlClient to access column's metadata contained in schemas returned
+ * by GetTables and query execution as follows:
+ * <pre>
+ *   FlightSqlColumnMetadata metadata = new FlightSqlColumnMetadata(field.getMetadata());
+ *   Integer precision = metadata.getPrecision();
+ * </pre>
+ *
+ * FlightSqlProducer can use this to set metadata on a column in a schema as follows:
+ * <pre>
+ *   FlightSqlColumnMetadata metadata = new FlightSqlColumnMetadata.Builder()
+ *         .precision(10)
+ *         .scale(5)
+ *         .build();
+ *   Field field = new Field("column", new FieldType(..., metadata.getMetadataMap()), null);
+ * </pre>
+ */
+public class FlightSqlColumnMetadata {
+
+  private static final String CATALOG_NAME = "CATALOG_NAME";
+  private static final String SCHEMA_NAME = "SCHEMA_NAME";
+  private static final String TABLE_NAME = "TABLE_NAME";
+  private static final String PRECISION = "PRECISION";
+  private static final String SCALE = "SCALE";
+  private static final String IS_AUTO_INCREMENT = "IS_AUTO_INCREMENT";
+  private static final String IS_CASE_SENSITIVE = "IS_CASE_SENSITIVE";
+  private static final String IS_READ_ONLY = "IS_READ_ONLY";
+  private static final String IS_SEARCHABLE = "IS_SEARCHABLE";
+
+  private static final String BOOLEAN_TRUE_STR = "1";
+  private static final String BOOLEAN_FALSE_STR = "0";
+
+  private final Map<String, String> metadataMap;
+
+  /**
+   * Creates a new instance of FlightSqlColumnMetadata.
+   */
+  public FlightSqlColumnMetadata(Map<String, String> metadataMap) {
+    this.metadataMap = metadataMap;

Review comment:
       Is it necessary? The ColumnMetadata doesn't have setter, it is only constructor through the builder. 




-- 
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: github-unsubscribe@arrow.apache.org

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