emkornfield commented on a change in pull request #9368: URL: https://github.com/apache/arrow/pull/9368#discussion_r567492525
########## File path: java/flight/flight-sql/src/main/java/org/apache/arrow/flight/sql/FlightSQLUtils.java ########## @@ -0,0 +1,203 @@ +/* + * 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.sql.Types; +import java.util.List; + +import org.apache.arrow.flight.ActionType; +import org.apache.arrow.vector.types.DateUnit; +import org.apache.arrow.vector.types.FloatingPointPrecision; +import org.apache.arrow.vector.types.TimeUnit; +import org.apache.arrow.vector.types.pojo.ArrowType; + +import com.google.common.collect.ImmutableList; +import com.google.protobuf.Any; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Message; + +/** + * Utilities to work with Flight SQL semantics. + */ +public final class FlightSQLUtils { + + private static final int BIT_WIDTH8 = 8; + private static final int BIT_WIDTH_16 = 16; + private static final int BIT_WIDTH_32 = 32; + private static final int BIT_WIDTH_64 = 64; + private static final boolean IS_SIGNED_FALSE = false; + private static final boolean IS_SIGNED_TRUE = true; + + public static final ActionType FLIGHT_SQL_GETSQLINFO = new ActionType("GetSQLINFO", + "Retrieves details of SQL capabilities of the Flight server. \n" + + "Request Message: N/A\n" + + "Response Message: ActionGetSQLInfoResult"); + + public static final ActionType FLIGHT_SQL_GETCATALOGS = new ActionType("GetCatalogs", + "Retrieves a list of all catalogs available on the server. \n" + + "Request Message: ActionGetCatalogsRequest\n" + + "Response Message: ActionGetCatalogsResult"); + + public static final ActionType FLIGHT_SQL_GETSCHEMAS = new ActionType("GetSchemas", + "Retrieves a list of schemas available on the server. \n" + + "Request Message: ActionGetSchemasRequest\n" + + "Response Message: ActionGetSchemasResult"); + + public static final ActionType FLIGHT_SQL_GETTABLES = new ActionType("GetTables", + "Retrieves a list of tables available on the server. \n" + + "Request Message: ActionGetTablesRequest\n" + + "Response Message: ActionGetTablesResult"); + + public static final ActionType FLIGHT_SQL_GETTABLETYPES = new ActionType("GetTableTypes", + "Retrieves a list of table types available on the server. \n" + + "Request Message: N/A\n" + + "Response Message: ActionGetTableTypesResult"); + + public static final ActionType FLIGHT_SQL_GETPREPAREDSTATEMENT = new ActionType("GetPreparedStatement", + "Creates a reusable prepared statement resource on the server. \n" + + "Request Message: ActionGetPreparedStatementRequest\n" + + "Response Message: ActionGetPreparedStatementResult"); + + public static final ActionType FLIGHT_SQL_CLOSEPREPAREDSTATEMENT = new ActionType("ClosePreparedStatement", + "Closes a reusable prepared statement resource on the server. \n" + + "Request Message: ActionClosePreparedStatementRequest\n" + + "Response Message: N/A"); + + public static final List<ActionType> FLIGHT_SQL_ACTIONS = ImmutableList.of( + FLIGHT_SQL_GETSQLINFO, + FLIGHT_SQL_GETCATALOGS, + FLIGHT_SQL_GETSCHEMAS, + FLIGHT_SQL_GETTABLES, + FLIGHT_SQL_GETTABLETYPES, + FLIGHT_SQL_GETPREPAREDSTATEMENT, + FLIGHT_SQL_CLOSEPREPAREDSTATEMENT + ); + + /** + * Converts {@link java.sql.Types} values returned from JDBC Apis to Arrow types. + * + * @param jdbcDataType {@link java.sql.Types} value. + * @param precision Precision of the type. + * @param scale Scale of the type. + * @return The Arrow equivalent type. + */ + public static ArrowType getArrowTypeFromJDBCType(int jdbcDataType, int precision, int scale) { Review comment: this duplicates code in the jdbc to arrow package i believe, can we consolidate it? I also thing there might be the need for custom mappings (we needed it JDBC conversion) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
