Class FlightSqlResolver
- All Implemented Interfaces:
ActionResolver,CommandResolver,TicketResolver
This implementation does not currently follow the Flight SQL protocol to exact specification. Namely, all the
returned Flight schemas have nullable fields, and some of the fields on specific
commands have different types (see flightInfoFor(SessionState, FlightDescriptor, String) for specifics).
All commands, actions, and resolution must be called by authenticated users.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.deephaven.server.session.TicketResolver
TicketResolver.Authorization -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoAction(@Nullable SessionState session, org.apache.arrow.flight.Action action, io.grpc.stub.StreamObserver<org.apache.arrow.flight.Result> observer) Executes the givenaction.SessionState.ExportObject<org.apache.arrow.flight.impl.Flight.FlightInfo>flightInfoFor(@Nullable SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId) Executes the givendescriptorcommand.voidforAllFlightInfo(@Nullable SessionState session, Consumer<org.apache.arrow.flight.impl.Flight.FlightInfo> visitor) Supports unauthenticated access.getLogNameFor(ByteBuffer ticket, String logId) Create a human readable string to identify this ticket.booleanhandlesActionType(String type) Returnstrueiftypeis a known Flight SQL action type (even if this implementation does not implement it).booleanhandlesCommand(org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor) Returnstrueif the given commanddescriptorappears to be a valid Flight SQL command; that is, it is parsable as anAnyprotobuf message with the type URL prefixed with "type.googleapis.com/arrow.flight.protocol.sql.Command".voidlistActions(@Nullable SessionState session, Consumer<org.apache.arrow.flight.ActionType> visitor) Supports unauthenticated access.<T> SessionState.ExportBuilder<T>publish(SessionState session, ByteBuffer ticket, String logId, @Nullable Runnable onPublish) Publishing to Flight SQL tickets is not currently supported.<T> SessionState.ExportBuilder<T>publish(SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId, @Nullable Runnable onPublish) Publishing to Flight SQL descriptors is not currently supported.<T> SessionState.ExportObject<T>resolve(@Nullable SessionState session, ByteBuffer ticket, String logId) Only supports authenticated access.<T> SessionState.ExportObject<T>resolve(@Nullable SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId) Resolve a flight descriptor to an export object future.byteThe Flight SQL ticket route, equal to 'q'.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.deephaven.server.session.TicketResolver
publish
-
Constructor Details
-
FlightSqlResolver
-
-
Method Details
-
ticketRoute
public byte ticketRoute()The Flight SQL ticket route, equal to 'q'.- Specified by:
ticketRoutein interfaceTicketResolver- Returns:
- the Flight SQL ticket route
-
handlesCommand
public boolean handlesCommand(org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor) Returnstrueif the given commanddescriptorappears to be a valid Flight SQL command; that is, it is parsable as anAnyprotobuf message with the type URL prefixed with "type.googleapis.com/arrow.flight.protocol.sql.Command".- Specified by:
handlesCommandin interfaceCommandResolver- Parameters:
descriptor- the descriptor- Returns:
trueif the given command appears to be a valid Flight SQL command
-
flightInfoFor
public SessionState.ExportObject<org.apache.arrow.flight.impl.Flight.FlightInfo> flightInfoFor(@Nullable @Nullable SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId) Executes the givendescriptorcommand. Only supports authenticated access.FlightSql.CommandStatementQuery: Executes the given SQL query. The returned Flight info should be promptly resolved, and resolved at most once. Transactions are not currently supported.FlightSql.CommandPreparedStatementQuery: Executes the prepared SQL query (must be executed within the scope of aFlightSqlUtils.FLIGHT_SQL_CREATE_PREPARED_STATEMENT/FlightSqlUtils.FLIGHT_SQL_CLOSE_PREPARED_STATEMENT). The returned Flight info should be promptly resolved, and resolved at most once.FlightSql.CommandGetTables: Retrieve the tables authorized for the user. The "table_name", "table_type", and (optional) "table_schema" fields will be out-of-spec as nullable columns (the returned data for these columns will never benull).FlightSql.CommandGetCatalogs: Retrieves the catalogs authorized for the user. The "catalog_name" field will be out-of-spec as a nullable column (the returned data for this column will never benull). Currently, always an empty table.FlightSql.CommandGetDbSchemas: Retrieves the catalogs and schemas authorized for the user. The "db_schema_name" field will be out-of-spec as a nullable (the returned data for this column will never benull). Currently, always an empty table.FlightSql.CommandGetTableTypes: Retrieves the table types authorized for the user. The "table_type" field will be out-of-spec as a nullable (the returned data for this column will never benull). Currently, always a table with a single row with value "TABLE".FlightSql.CommandGetPrimaryKeys: Retrieves the primary keys for a table if the user is authorized. If the table does not exist (or the user is not authorized), aStatus.Code.NOT_FOUNDexception will be thrown. The "table_name", "column_name", and "key_sequence" will be out-of-spec as nullable columns (the returned data for these columns will never benull). Currently, always an empty table.FlightSql.CommandGetImportedKeys: Retrieves the imported keys for a table if the user is authorized. If the table does not exist (or the user is not authorized), aStatus.Code.NOT_FOUNDexception will be thrown. The "pk_table_name", "pk_column_name", "fk_table_name", "fk_column_name", and "key_sequence" will be out-of-spec as nullable columns (the returned data for these columns will never benull). The "update_rule" and "delete_rule" will be out-of-spec as nullableint8types instead ofuint8(the returned data for these columns will never benull). Currently, always an empty table.FlightSql.CommandGetExportedKeys: Retrieves the exported keys for a table if the user is authorized. If the table does not exist (or the user is not authorized), aStatus.Code.NOT_FOUNDexception will be thrown. The "pk_table_name", "pk_column_name", "fk_table_name", "fk_column_name", and "key_sequence" will be out-of-spec as nullable columns (the returned data for these columns will never benull). The "update_rule" and "delete_rule" will be out-of-spec as nullableint8types instead ofuint8(the returned data for these columns will never benull). Currently, always an empty table.All other commands will throw an
Status.Code.UNIMPLEMENTEDexception.- Specified by:
flightInfoForin interfaceTicketResolver- Parameters:
session- the sessiondescriptor- the flight descriptor to retrieve a ticket forlogId- an end-user friendly identification of the ticket should an error occur- Returns:
- the flight info for the given
descriptorcommand
-
resolve
public <T> SessionState.ExportObject<T> resolve(@Nullable @Nullable SessionState session, ByteBuffer ticket, String logId) Only supports authenticated access.- Specified by:
resolvein interfaceTicketResolver- Type Parameters:
T- the type, must be Table- Parameters:
session- the user session contextticket- (as ByteByffer) the ticket to resolvelogId- an end-user friendly identification of the ticket should an error occur- Returns:
- the exported table
-
resolve
public <T> SessionState.ExportObject<T> resolve(@Nullable @Nullable SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId) Description copied from interface:TicketResolverResolve a flight descriptor to an export object future.- Specified by:
resolvein interfaceTicketResolver- Type Parameters:
T- the expected return type of the ticket; this is not validated- Parameters:
session- the user session contextdescriptor- the descriptor to resolvelogId- an end-user friendly identification of the ticket should an error occur- Returns:
- an export object; see
SessionStatefor lifecycle propagation details
-
listActions
public void listActions(@Nullable @Nullable SessionState session, Consumer<org.apache.arrow.flight.ActionType> visitor) Supports unauthenticated access. When unauthenticated, will not return any actions types. When authenticated, will return the action types the user is authorized to access. Currently, supportsFlightSqlUtils.FLIGHT_SQL_CREATE_PREPARED_STATEMENTandFlightSqlUtils.FLIGHT_SQL_CLOSE_PREPARED_STATEMENT.- Specified by:
listActionsin interfaceActionResolver- Parameters:
session- the sessionvisitor- the visitor
-
handlesActionType
Returnstrueiftypeis a known Flight SQL action type (even if this implementation does not implement it).- Specified by:
handlesActionTypein interfaceActionResolver- Parameters:
type- the action type- Returns:
- if
typeis a known Flight SQL action type
-
doAction
public void doAction(@Nullable @Nullable SessionState session, org.apache.arrow.flight.Action action, io.grpc.stub.StreamObserver<org.apache.arrow.flight.Result> observer) Executes the givenaction. Only supports authenticated access. Currently, supportsFlightSqlUtils.FLIGHT_SQL_CREATE_PREPARED_STATEMENTandFlightSqlUtils.FLIGHT_SQL_CLOSE_PREPARED_STATEMENT; all other action types will throw anStatus.Code.UNIMPLEMENTEDexception. Transactions are not currently supported.- Specified by:
doActionin interfaceActionResolver- Parameters:
session- the sessionaction- the actionobserver- the observer
-
forAllFlightInfo
public void forAllFlightInfo(@Nullable @Nullable SessionState session, Consumer<org.apache.arrow.flight.impl.Flight.FlightInfo> visitor) Supports unauthenticated access. When unauthenticated, will not return any Flight info. When authenticated, this may return Flight info the user is authorized to access. Currently, no Flight info is returned.- Specified by:
forAllFlightInfoin interfaceTicketResolver- Parameters:
session- optional session that the resolver can use to filter which flights a visitor seesvisitor- the callback to invoke per descriptor path
-
publish
public <T> SessionState.ExportBuilder<T> publish(SessionState session, org.apache.arrow.flight.impl.Flight.FlightDescriptor descriptor, String logId, @Nullable @Nullable Runnable onPublish) Publishing to Flight SQL descriptors is not currently supported. Throws aStatus.Code.FAILED_PRECONDITIONerror.- Specified by:
publishin interfaceTicketResolver- Type Parameters:
T- the type of the result the export will publish- Parameters:
session- the user session contextdescriptor- (as Flight.Descriptor) the descriptor to publish tologId- an end-user friendly identification of the ticket should an error occuronPublish- an optional callback to invoke when the result is published- Returns:
- an export object; see
SessionStatefor lifecycle propagation details
-
publish
public <T> SessionState.ExportBuilder<T> publish(SessionState session, ByteBuffer ticket, String logId, @Nullable @Nullable Runnable onPublish) Publishing to Flight SQL tickets is not currently supported. Throws aStatus.Code.FAILED_PRECONDITIONerror.- Specified by:
publishin interfaceTicketResolver- Type Parameters:
T- the type of the result the export will publish- Parameters:
session- the user session contextticket- (as ByteByffer) the ticket to publish tologId- an end-user friendly identification of the ticket should an error occuronPublish- an optional callback to invoke when the result is published- Returns:
- an export object; see
SessionStatefor lifecycle propagation details
-
getLogNameFor
Description copied from interface:TicketResolverCreate a human readable string to identify this ticket.- Specified by:
getLogNameForin interfaceTicketResolver- Parameters:
ticket- the ticket to parselogId- an end-user friendly identification of the ticket should an error occur- Returns:
- a string that is good for log/error messages
-