You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2025/06/10 07:04:45 UTC
[PR] IGNITE-25487 [ignite-3]
xtern opened a new pull request, #6011:
URL: https://github.com/apache/ignite-3/pull/6011
https://issues.apache.org/jira/browse/IGNITE-25487
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern merged PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144707484
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -129,25 +149,69 @@ private CompletableFuture<Collection<CatalogTableDescriptor>> tablesAtNow() {
* @param tblTypes Requested table types.
* @return Future of the list of metadatas of tables that matches.
*/
- public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, String[] tblTypes) {
+ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, @Nullable String[] tblTypes) {
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
-
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
+ boolean[] includedTblTypes = resolveTableTypes(tblTypes);
+
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema -> {
+ Stream<JdbcTableMeta> tablesStream = includedTblTypes[TYPE_TABLE_IDX]
Review Comment:
Let's avoid flags by introducing enums for table types,
and hide if-else logic into separate method by the type. e.g. `getCatalogObjects` below:
```
TableTypeEnum[] types;
schema;
types.stream().map(type -> getCatalogObjects(schema, type))
.filter(o -> matches(o.name(), tlbNameRegex))
.map(t -> new JdbcTableMeta(schema.name(), t.name(), type))
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144707484
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -129,25 +149,69 @@ private CompletableFuture<Collection<CatalogTableDescriptor>> tablesAtNow() {
* @param tblTypes Requested table types.
* @return Future of the list of metadatas of tables that matches.
*/
- public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, String[] tblTypes) {
+ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, @Nullable String[] tblTypes) {
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
-
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
+ boolean[] includedTblTypes = resolveTableTypes(tblTypes);
+
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema -> {
+ Stream<JdbcTableMeta> tablesStream = includedTblTypes[TYPE_TABLE_IDX]
Review Comment:
TableTypeEnum[] types;
schema;
types.stream().map(type -> getCatalogObjects(schema, type))
.filter(o -> matches(o.name(), tlbNameRegex))
.map(t -> new JdbcTableMeta(schema.name(), t.name(), type))
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2140145745
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -133,21 +147,22 @@ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtr
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
- }
-
- private static boolean tableNameAndSchemaMatches(
- CatalogTableDescriptor table,
- @Nullable String schemaNameRegex,
- @Nullable String tlbNameRegex
- ) {
- return matches(SqlCommon.DEFAULT_SCHEMA_NAME, schemaNameRegex) && matches(table.name(), tlbNameRegex);
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
Missed this one.
Thanks fixed.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144920209
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -129,25 +149,69 @@ private CompletableFuture<Collection<CatalogTableDescriptor>> tablesAtNow() {
* @param tblTypes Requested table types.
* @return Future of the list of metadatas of tables that matches.
*/
- public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, String[] tblTypes) {
+ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, @Nullable String[] tblTypes) {
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
-
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
+ boolean[] includedTblTypes = resolveTableTypes(tblTypes);
+
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema -> {
+ Stream<JdbcTableMeta> tablesStream = includedTblTypes[TYPE_TABLE_IDX]
Review Comment:
Done, thanks
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144876503
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -165,19 +229,29 @@ public CompletableFuture<Collection<JdbcColumnMeta>> getColumnsMeta(String schem
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
String colNameRegex = translateSqlWildcardsToRegex(colNamePtrn);
- return tablesAtNow().thenApply(tablesList -> tablesList.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .flatMap(
- tbl -> {
- SchemaDescriptor schema = CatalogToSchemaDescriptorConverter.convert(tbl, tbl.tableVersion());
-
- return schema.columns().stream()
- .map(column -> new Pair<>(tbl.name(), column));
- })
- .filter(e -> matches(e.getSecond().name(), colNameRegex))
- .sorted(bySchemaThenTabNameThenColOrder)
- .map(pair -> createColumnMeta(pair.getFirst(), pair.getSecond()))
- .collect(toCollection(LinkedHashSet::new)));
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
I still don't like using Pair class just because of lack classes hierarchy.
It is better to introduce marker interface for that purposes
```
interface CatalogColumnContainer<T> {
String name();
List<T> columns();
}
```
This will make streams code clear.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144685596
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -101,19 +116,24 @@ public CompletableFuture<Collection<JdbcPrimaryKeyMeta>> getPrimaryKeys(String s
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
- return tablesAtNow()
- .thenApply(tables -> tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .map(this::createPrimaryKeyMeta)
- .collect(toSet())
- );
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Arrays.stream(schema.tables())
Review Comment:
```suggestion
.flatMap(schema -> Arrays.stream(schema.tables())
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144876503
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -165,19 +229,29 @@ public CompletableFuture<Collection<JdbcColumnMeta>> getColumnsMeta(String schem
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
String colNameRegex = translateSqlWildcardsToRegex(colNamePtrn);
- return tablesAtNow().thenApply(tablesList -> tablesList.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .flatMap(
- tbl -> {
- SchemaDescriptor schema = CatalogToSchemaDescriptorConverter.convert(tbl, tbl.tableVersion());
-
- return schema.columns().stream()
- .map(column -> new Pair<>(tbl.name(), column));
- })
- .filter(e -> matches(e.getSecond().name(), colNameRegex))
- .sorted(bySchemaThenTabNameThenColOrder)
- .map(pair -> createColumnMeta(pair.getFirst(), pair.getSecond()))
- .collect(toCollection(LinkedHashSet::new)));
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
I still don't like using Pair class just because of lack classes hierarchy.
It is better to introduce marker interface for that purposes
```
interface CatalogColumnContainer<T> {
String name();
List<T> columns();
}
```
This will make streams code clear.
Also, this allows to sort tables/views at early stage before unwrapping the columns.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144922520
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -211,30 +279,31 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
* @param tbl Table.
* @return Jdbc primary key metadata.
*/
- private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+ private static JdbcPrimaryKeyMeta createPrimaryKeyMeta(String schemaName, CatalogTableDescriptor tbl) {
String keyName = PK + tbl.name();
List<String> keyColNames = List.copyOf(tbl.primaryKeyColumns());
- return new JdbcPrimaryKeyMeta(SqlCommon.DEFAULT_SCHEMA_NAME, tbl.name(), keyName, keyColNames);
+ return new JdbcPrimaryKeyMeta(schemaName, tbl.name(), keyName, keyColNames);
}
/**
* Creates column metadata from column and table name.
*
+ * @param schemaName Schema name.
* @param tblName Table name.
- * @param col Column.
+ * @param col Column descriptor.
* @return Column metadata.
*/
- private JdbcColumnMeta createColumnMeta(String tblName, Column col) {
- NativeType colType = col.type();
+ private static JdbcColumnMeta createColumnMeta(String schemaName, String tblName, CatalogTableColumnDescriptor col) {
+ NativeType colType = TypeUtils.columnType2NativeType(col.type(), col.precision(), col.scale(), col.length());
Review Comment:
This method is used to correctly convert length to precision for VARLEN types
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144920549
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -165,19 +229,29 @@ public CompletableFuture<Collection<JdbcColumnMeta>> getColumnsMeta(String schem
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
String colNameRegex = translateSqlWildcardsToRegex(colNamePtrn);
- return tablesAtNow().thenApply(tablesList -> tablesList.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .flatMap(
- tbl -> {
- SchemaDescriptor schema = CatalogToSchemaDescriptorConverter.convert(tbl, tbl.tableVersion());
-
- return schema.columns().stream()
- .map(column -> new Pair<>(tbl.name(), column));
- })
- .filter(e -> matches(e.getSecond().name(), colNameRegex))
- .sorted(bySchemaThenTabNameThenColOrder)
- .map(pair -> createColumnMeta(pair.getFirst(), pair.getSecond()))
- .collect(toCollection(LinkedHashSet::new)));
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
Done, thanks
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2140145745
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -133,21 +147,22 @@ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtr
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
- }
-
- private static boolean tableNameAndSchemaMatches(
- CatalogTableDescriptor table,
- @Nullable String schemaNameRegex,
- @Nullable String tlbNameRegex
- ) {
- return matches(SqlCommon.DEFAULT_SCHEMA_NAME, schemaNameRegex) && matches(table.name(), tlbNameRegex);
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
Missed this.
Thanks fixed.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144707484
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -129,25 +149,69 @@ private CompletableFuture<Collection<CatalogTableDescriptor>> tablesAtNow() {
* @param tblTypes Requested table types.
* @return Future of the list of metadatas of tables that matches.
*/
- public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, String[] tblTypes) {
+ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtrn, String tblNamePtrn, @Nullable String[] tblTypes) {
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
-
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
+ boolean[] includedTblTypes = resolveTableTypes(tblTypes);
+
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema -> {
+ Stream<JdbcTableMeta> tablesStream = includedTblTypes[TYPE_TABLE_IDX]
Review Comment:
String[] types;
schema;
types.stream().map(type -> getCatalogObjects(schema, type))
.filter(o -> matches(o.name(), tlbNameRegex))
.map(t -> new JdbcTableMeta(schema.name(), t.name(), type))
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144844960
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -211,30 +279,31 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
* @param tbl Table.
* @return Jdbc primary key metadata.
*/
- private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+ private static JdbcPrimaryKeyMeta createPrimaryKeyMeta(String schemaName, CatalogTableDescriptor tbl) {
String keyName = PK + tbl.name();
List<String> keyColNames = List.copyOf(tbl.primaryKeyColumns());
- return new JdbcPrimaryKeyMeta(SqlCommon.DEFAULT_SCHEMA_NAME, tbl.name(), keyName, keyColNames);
+ return new JdbcPrimaryKeyMeta(schemaName, tbl.name(), keyName, keyColNames);
}
/**
* Creates column metadata from column and table name.
*
+ * @param schemaName Schema name.
* @param tblName Table name.
- * @param col Column.
+ * @param col Column descriptor.
* @return Column metadata.
*/
- private JdbcColumnMeta createColumnMeta(String tblName, Column col) {
- NativeType colType = col.type();
+ private static JdbcColumnMeta createColumnMeta(String schemaName, String tblName, CatalogTableColumnDescriptor col) {
+ NativeType colType = TypeUtils.columnType2NativeType(col.type(), col.precision(), col.scale(), col.length());
Review Comment:
```suggestion
```
Let's use precition/scale from column descriptor directly.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144919810
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -101,19 +116,24 @@ public CompletableFuture<Collection<JdbcPrimaryKeyMeta>> getPrimaryKeys(String s
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
- return tablesAtNow()
- .thenApply(tables -> tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .map(this::createPrimaryKeyMeta)
- .collect(toSet())
- );
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Arrays.stream(schema.tables())
Review Comment:
Done, thanks
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2139966831
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/internal/jdbc/ItJdbcMetadataSelfTest.java:
##########
@@ -60,11 +57,17 @@ public class ItJdbcMetadataSelfTest extends AbstractJdbcSelfTest {
@BeforeAll
public static void createTables() throws SQLException {
try (Statement stmt = conn.createStatement()) {
- stmt.executeUpdate("CREATE TABLE person(name VARCHAR, age INT, orgid INT PRIMARY KEY)");
- stmt.executeUpdate("INSERT INTO person (orgid, name, age) VALUES (1, '111', 111)");
-
- stmt.executeUpdate("CREATE TABLE organization(id INT PRIMARY KEY, name VARCHAR, bigdata DECIMAL(20, 10))");
- stmt.executeUpdate("INSERT INTO organization (id, name, bigdata) VALUES (1, 'AAA', 10)");
+ stmt.execute("CREATE SCHEMA IF NOT EXISTS PUBLIC;"
+ + "CREATE SCHEMA IF NOT EXISTS META;"
+ + "CREATE SCHEMA IF NOT EXISTS USER2;"
+ + "CREATE SCHEMA IF NOT EXISTS USER1;"
+ + "CREATE TABLE person(name VARCHAR(32), age INT, orgid INT PRIMARY KEY);"
+ + "CREATE TABLE organization(id INT PRIMARY KEY, name VARCHAR, bigdata DECIMAL(20, 10));"
Review Comment:
I think it will be good to add/amend one of them to casesensetive
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -133,21 +147,22 @@ public CompletableFuture<List<JdbcTableMeta>> getTablesMeta(String schemaNamePtr
String schemaNameRegex = translateSqlWildcardsToRegex(schemaNamePtrn);
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
- return tablesAtNow().thenApply(tables -> {
- return tables.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .sorted(byTblTypeThenSchemaThenTblName)
- .map(t -> new JdbcTableMeta(SqlCommon.DEFAULT_SCHEMA_NAME, t.name(), TBL_TYPE))
- .collect(toList());
- });
- }
-
- private static boolean tableNameAndSchemaMatches(
- CatalogTableDescriptor table,
- @Nullable String schemaNameRegex,
- @Nullable String tlbNameRegex
- ) {
- return matches(SqlCommon.DEFAULT_SCHEMA_NAME, schemaNameRegex) && matches(table.name(), tlbNameRegex);
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
seems ``tblTypes`` should be taking into account
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -211,30 +230,31 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
* @param tbl Table.
* @return Jdbc primary key metadata.
*/
- private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+ private static JdbcPrimaryKeyMeta createPrimaryKeyMeta(String schemaName, CatalogTableDescriptor tbl) {
String keyName = PK + tbl.name();
Review Comment:
we don't have a name for PK, maybe ``null`` is right value here
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2140146498
##########
modules/jdbc/src/integrationTest/java/org/apache/ignite/internal/jdbc/ItJdbcMetadataSelfTest.java:
##########
@@ -60,11 +57,17 @@ public class ItJdbcMetadataSelfTest extends AbstractJdbcSelfTest {
@BeforeAll
public static void createTables() throws SQLException {
try (Statement stmt = conn.createStatement()) {
- stmt.executeUpdate("CREATE TABLE person(name VARCHAR, age INT, orgid INT PRIMARY KEY)");
- stmt.executeUpdate("INSERT INTO person (orgid, name, age) VALUES (1, '111', 111)");
-
- stmt.executeUpdate("CREATE TABLE organization(id INT PRIMARY KEY, name VARCHAR, bigdata DECIMAL(20, 10))");
- stmt.executeUpdate("INSERT INTO organization (id, name, bigdata) VALUES (1, 'AAA', 10)");
+ stmt.execute("CREATE SCHEMA IF NOT EXISTS PUBLIC;"
+ + "CREATE SCHEMA IF NOT EXISTS META;"
+ + "CREATE SCHEMA IF NOT EXISTS USER2;"
+ + "CREATE SCHEMA IF NOT EXISTS USER1;"
+ + "CREATE TABLE person(name VARCHAR(32), age INT, orgid INT PRIMARY KEY);"
+ + "CREATE TABLE organization(id INT PRIMARY KEY, name VARCHAR, bigdata DECIMAL(20, 10));"
Review Comment:
Test coverage improved, thanks
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2144744331
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -165,19 +229,29 @@ public CompletableFuture<Collection<JdbcColumnMeta>> getColumnsMeta(String schem
String tlbNameRegex = translateSqlWildcardsToRegex(tblNamePtrn);
String colNameRegex = translateSqlWildcardsToRegex(colNamePtrn);
- return tablesAtNow().thenApply(tablesList -> tablesList.stream()
- .filter(t -> tableNameAndSchemaMatches(t, schemaNameRegex, tlbNameRegex))
- .flatMap(
- tbl -> {
- SchemaDescriptor schema = CatalogToSchemaDescriptorConverter.convert(tbl, tbl.tableVersion());
-
- return schema.columns().stream()
- .map(column -> new Pair<>(tbl.name(), column));
- })
- .filter(e -> matches(e.getSecond().name(), colNameRegex))
- .sorted(bySchemaThenTabNameThenColOrder)
- .map(pair -> createColumnMeta(pair.getFirst(), pair.getSecond()))
- .collect(toCollection(LinkedHashSet::new)));
+ return schemasAtNow().thenApply(schemas ->
+ schemas.stream()
+ .filter(schema -> matches(schema.name(), schemaNameRegex))
+ .flatMap(schema ->
+ Stream.concat(
+ Arrays.stream(schema.systemViews())
Review Comment:
```suggestion
stream.concat( Arrays.stream(schema.systemViews())
.map(o -> new Pair(o, o.columns())),
Arrays.stream(schema.tables())
.map(o -> new Pair(o, o.columns()))
)
.filter(p -> matches(p.get1().name(), tlbNameRegex))
.flatMap(p -> p.get2().stream()
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-25487 Schema aware JDBC metadata [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #6011:
URL: https://github.com/apache/ignite-3/pull/6011#discussion_r2139963945
##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -211,30 +230,31 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
* @param tbl Table.
* @return Jdbc primary key metadata.
*/
- private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+ private static JdbcPrimaryKeyMeta createPrimaryKeyMeta(String schemaName, CatalogTableDescriptor tbl) {
String keyName = PK + tbl.name();
Review Comment:
we don't have a name for PK, maybe ``null`` is right value here
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org