in flight/flight-sql/src/main/java/org/apache/arrow/flight/sql/FlightSqlProducer.java [173:217]
default SchemaResult getSchema(CallContext context, FlightDescriptor descriptor) {
final Any command = FlightSqlUtils.parseOrThrow(descriptor.getCommand());
if (command.is(CommandStatementQuery.class)) {
return getSchemaStatement(
FlightSqlUtils.unpackOrThrow(command, CommandStatementQuery.class), context, descriptor);
} else if (command.is(CommandPreparedStatementQuery.class)) {
return getSchemaPreparedStatement(
FlightSqlUtils.unpackOrThrow(command, CommandPreparedStatementQuery.class),
context,
descriptor);
} else if (command.is(CommandStatementSubstraitPlan.class)) {
return getSchemaSubstraitPlan(
FlightSqlUtils.unpackOrThrow(command, CommandStatementSubstraitPlan.class),
context,
descriptor);
} else if (command.is(CommandGetCatalogs.class)) {
return new SchemaResult(Schemas.GET_CATALOGS_SCHEMA);
} else if (command.is(CommandGetCrossReference.class)) {
return new SchemaResult(Schemas.GET_CROSS_REFERENCE_SCHEMA);
} else if (command.is(CommandGetDbSchemas.class)) {
return new SchemaResult(Schemas.GET_SCHEMAS_SCHEMA);
} else if (command.is(CommandGetExportedKeys.class)) {
return new SchemaResult(Schemas.GET_EXPORTED_KEYS_SCHEMA);
} else if (command.is(CommandGetImportedKeys.class)) {
return new SchemaResult(Schemas.GET_IMPORTED_KEYS_SCHEMA);
} else if (command.is(CommandGetPrimaryKeys.class)) {
return new SchemaResult(Schemas.GET_PRIMARY_KEYS_SCHEMA);
} else if (command.is(CommandGetTables.class)) {
if (FlightSqlUtils.unpackOrThrow(command, CommandGetTables.class).getIncludeSchema()) {
return new SchemaResult(Schemas.GET_TABLES_SCHEMA);
}
return new SchemaResult(Schemas.GET_TABLES_SCHEMA_NO_SCHEMA);
} else if (command.is(CommandGetTableTypes.class)) {
return new SchemaResult(Schemas.GET_TABLE_TYPES_SCHEMA);
} else if (command.is(CommandGetSqlInfo.class)) {
return new SchemaResult(Schemas.GET_SQL_INFO_SCHEMA);
} else if (command.is(CommandGetXdbcTypeInfo.class)) {
return new SchemaResult(Schemas.GET_TYPE_INFO_SCHEMA);
}
throw CallStatus.INVALID_ARGUMENT
.withDescription("Unrecognized request: " + command.getTypeUrl())
.toRuntimeException();
}