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

ARROW-17659: [Java] Populate JDBC schema name metadata when config.shouldIncludeMetadata provided #14196

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Constants {
private Constants() {}

public static final String SQL_CATALOG_NAME_KEY = "SQL_CATALOG_NAME";
public static final String SQL_SCHEMA_NAME_KEY = "SQL_SCHEMA_NAME";
public static final String SQL_TABLE_NAME_KEY = "SQL_TABLE_NAME";
public static final String SQL_COLUMN_NAME_KEY = "SQL_COLUMN_NAME";
public static final String SQL_TYPE_KEY = "SQL_TYPE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public static Schema jdbcToArrowSchema(ResultSetMetaData rsmd, JdbcToArrowConfig
if (config.shouldIncludeMetadata()) {
metadata = new HashMap<>();
metadata.put(Constants.SQL_CATALOG_NAME_KEY, rsmd.getCatalogName(i));
metadata.put(Constants.SQL_SCHEMA_NAME_KEY, rsmd.getSchemaName(i));
metadata.put(Constants.SQL_TABLE_NAME_KEY, rsmd.getTableName(i));
metadata.put(Constants.SQL_COLUMN_NAME_KEY, columnName);
metadata.put(Constants.SQL_TYPE_KEY, rsmd.getColumnTypeName(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,10 @@ public static void assertFieldMetadataMatchesResultSetMetadata(ResultSetMetaData
Map<String, String> metadata = fields.get(i - 1).getMetadata();

assertNotNull(metadata);
assertEquals(4, metadata.size());
assertEquals(5, metadata.size());

assertEquals(rsmd.getCatalogName(i), metadata.get(Constants.SQL_CATALOG_NAME_KEY));
assertEquals(rsmd.getSchemaName(i), metadata.get(Constants.SQL_SCHEMA_NAME_KEY));
assertEquals(rsmd.getTableName(i), metadata.get(Constants.SQL_TABLE_NAME_KEY));
assertEquals(rsmd.getColumnLabel(i), metadata.get(Constants.SQL_COLUMN_NAME_KEY));
assertEquals(rsmd.getColumnTypeName(i), metadata.get(Constants.SQL_TYPE_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
},
"children" : [ ],
"metadata" : [ {
"value" : "Record identifier",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
"value" : "PUBLIC",
"key" : "SQL_SCHEMA_NAME"
}, {
"value" : "JDBCTOARROWTEST?CHARACTERENCODING=UTF-8",
"key" : "SQL_CATALOG_NAME"
Expand All @@ -23,6 +20,12 @@
}, {
"value" : "BIGINT",
"key" : "SQL_TYPE"
}, {
"value" : "Record identifier",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
} ]
}, {
"name" : "NAME",
Expand All @@ -32,11 +35,8 @@
},
"children" : [ ],
"metadata" : [ {
"value" : "Name of record",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
"value" : "PUBLIC",
"key" : "SQL_SCHEMA_NAME"
}, {
"value" : "JDBCTOARROWTEST?CHARACTERENCODING=UTF-8",
"key" : "SQL_CATALOG_NAME"
Expand All @@ -46,6 +46,12 @@
}, {
"value" : "VARCHAR",
"key" : "SQL_TYPE"
}, {
"value" : "Name of record",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
} ]
}, {
"name" : "COLUMN1",
Expand All @@ -55,6 +61,9 @@
},
"children" : [ ],
"metadata" : [ {
"value" : "PUBLIC",
"key" : "SQL_SCHEMA_NAME"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
}, {
Expand All @@ -77,11 +86,8 @@
},
"children" : [ ],
"metadata" : [ {
"value" : "Informative description of columnN",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
"value" : "PUBLIC",
"key" : "SQL_SCHEMA_NAME"
}, {
"value" : "JDBCTOARROWTEST?CHARACTERENCODING=UTF-8",
"key" : "SQL_CATALOG_NAME"
Expand All @@ -91,6 +97,12 @@
}, {
"value" : "INTEGER",
"key" : "SQL_TYPE"
}, {
"value" : "Informative description of columnN",
"key" : "comment"
}, {
"value" : "TABLE1",
"key" : "SQL_TABLE_NAME"
} ]
} ],
"metadata" : [ {
Expand Down