Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java][FlightSQL] Inconsistent GET_PRIMARY_KEYS_SCHEMA #45233

Open
devinrsmith opened this issue Oct 23, 2024 · 3 comments
Open

[Java][FlightSQL] Inconsistent GET_PRIMARY_KEYS_SCHEMA #45233

devinrsmith opened this issue Oct 23, 2024 · 3 comments

Comments

@devinrsmith
Copy link
Contributor

Describe the bug, including details regarding any error messages, version, and platform.

The protobuf documentation 1 for the returned schema of FlightSQL CommandGetPrimaryKeys is

 *  catalog_name: utf8,
 *  db_schema_name: utf8,
 *  table_name: utf8 not null,
 *  column_name: utf8 not null,
 *  key_name: utf8,
 *  key_sequence: int32 not null

org.apache.arrow.flight.sql.FlightSqlProducer.Schemas#GET_PRIMARY_KEYS_SCHEMA 2 is defined as

    public static final Schema GET_PRIMARY_KEYS_SCHEMA =
        new Schema(asList(
            Field.nullable("catalog_name", VARCHAR.getType()),
            Field.nullable("db_schema_name", VARCHAR.getType()),
            Field.notNullable("table_name", VARCHAR.getType()),
            Field.notNullable("column_name", VARCHAR.getType()),
            Field.notNullable("key_sequence", INT.getType()),
            Field.nullable("key_name", VARCHAR.getType())));

Note the reordering of key_name and key_sequence.

Should this be considered a bug in the implementation or the documentation? Or, is field order "unimportant" in this context?

Component(s)

Java

Footnotes

  1. https://github.com/apache/arrow/blob/apache-arrow-17.0.0/format/FlightSql.proto#L1280-L1285

  2. https://github.com/apache/arrow/blob/apache-arrow-17.0.0/java/flight/flight-sql/src/main/java/org/apache/arrow/flight/sql/FlightSqlProducer.java#L1164-L1172

@lidavidm
Copy link
Member

C++ agrees with Java:

const std::shared_ptr<Schema>& SqlSchema::GetPrimaryKeysSchema() {
static std::shared_ptr<Schema> kSchema = arrow::schema(
{field("catalog_name", utf8()), field("db_schema_name", utf8()),
field("table_name", utf8(), false), field("column_name", utf8(), false),
field("key_sequence", int32(), false), field("key_name", utf8())});
return kSchema;
}

So does Go:

https://github.com/apache/arrow-go/blob/56b794f52a9bfb45fb54a4e070002a69b38fb018/arrow/flight/flightsql/schema_ref/reference_schemas.go#L46-L53

I'd consider this a bug in the documentation.

@assignUser assignUser transferred this issue from apache/arrow Nov 26, 2024
@lidavidm lidavidm transferred this issue from apache/arrow-java Jan 13, 2025
@lidavidm
Copy link
Member

Transferred this back since I believe it is a documentation bug.

@lidavidm
Copy link
Member

@jduo might you have any comments here? If the order in the source code is correct, does this documentation comment also need to be updated?

 * The returned data should be ordered by catalog_name, db_schema_name, table_name, key_name, then key_sequence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants