You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "lowka (via GitHub)" <gi...@apache.org> on 2025/02/11 08:58:34 UTC
[PR] IGNITE-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
lowka opened a new pull request, #5210:
URL: https://github.com/apache/ignite-3/pull/5210
Introduces a schema contaner to resolve this issue - `SqlSchemaManager` now returns a top level schema container instead of a default schema.
https://issues.apache.org/jira/browse/IGNITE-24456
---
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1954176340
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.sql.engine.prepare;
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
Review Comment:
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1953106926
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -226,21 +226,28 @@ public CompletableFuture<QueryPlan> prepareAsync(
assert schemaName != null;
- SchemaPlus schema = schemaManager.schema(operationContext.operationTime().longValue())
- .getSubSchema(schemaName);
-
- if (schema == null) {
- return CompletableFuture.failedFuture(new SchemaNotFoundException(schemaName));
Review Comment:
I believe this was the last place where this exception (SchemaNotFoundException) and code (SCHEMA_NOT_FOUND_ERR) was used.
So it might be worth removing them.
##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItSchemaTest.java:
##########
@@ -181,4 +181,56 @@ public void schemaQuoted() {
);
}
}
+
+ @Test
+ public void accessTheSameObject() {
+ sql("CREATE SCHEMA s1");
+ sql("CREATE TABLE s1.t1 (id INT PRIMARY KEY, val INT)");
+
+ // Works fine
+ assertQuery("SELECT count(*) FROM s1.t1")
+ .returns(0L)
+ .check();
+
+ // Works fine
+ assertQuery("SELECT count(*) FROM t1")
+ .withDefaultSchema("S1")
+ .returns(0L)
+ .check();
+
+ // Should work as wee, because we do not access the MISSING schema,
+ // but we get Schema not found instead.
Review Comment:
```suggestion
// Works fine, because we do not access the MISSING schema.
```
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteSchemas.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.engine.schema;
+
+import org.apache.calcite.schema.SchemaPlus;
+
+/**
+ * Schema container.
+ */
+public final class IgniteSchemas {
+
+ private final SchemaPlus rootSchema;
+
+ private final int catalogVersion;
+
+ /**
+ * Constructor.
+ *
+ * @param rootSchema Root schema.
+ * @param catalogVersion Catalog version.
+ */
+ public IgniteSchemas(SchemaPlus rootSchema, int catalogVersion) {
+ this.rootSchema = rootSchema;
+ this.catalogVersion = catalogVersion;
+ }
+
+ /**
+ * Returns a {@link SchemaPlus} that contains all catalog schemas.
+ *
+ * @return Root schema.
+ */
+ public SchemaPlus root() {
+ return rootSchema;
+ }
+
+ /**
+ * Returns catalog version this schemas belong to.
Review Comment:
```suggestion
* Returns catalog version these schemas belong to.
```
or... "this schema container belong**s** to." :thinking:
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern merged PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1952683178
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -226,21 +227,29 @@ public CompletableFuture<QueryPlan> prepareAsync(
assert schemaName != null;
- SchemaPlus schema = schemaManager.schema(operationContext.operationTime().longValue())
- .getSubSchema(schemaName);
-
- if (schema == null) {
- return CompletableFuture.failedFuture(new SchemaNotFoundException(schemaName));
+ IgniteSchemas rootSchema = schemaManager.schemas(operationContext.operationTime().longValue());
+ if (rootSchema == null) {
+ return CompletableFuture.failedFuture(new SchemaNotFoundException("Root schema"));
Review Comment:
I don't understand such an error and can't imagine what the should user do in this case.
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "ygerzhedovich (via GitHub)" <gi...@apache.org>.
ygerzhedovich commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1952734998
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.sql.engine.prepare;
+import static org.apache.ignite.internal.lang.IgniteStringFormatter.format;
Review Comment:
looks like should be deleted
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1952732415
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/PrepareServiceImpl.java:
##########
@@ -226,21 +227,29 @@ public CompletableFuture<QueryPlan> prepareAsync(
assert schemaName != null;
- SchemaPlus schema = schemaManager.schema(operationContext.operationTime().longValue())
- .getSubSchema(schemaName);
-
- if (schema == null) {
- return CompletableFuture.failedFuture(new SchemaNotFoundException(schemaName));
+ IgniteSchemas rootSchema = schemaManager.schemas(operationContext.operationTime().longValue());
+ if (rootSchema == null) {
+ return CompletableFuture.failedFuture(new SchemaNotFoundException("Root schema"));
Review Comment:
Thanks. Replaced it with an assertion because it looks like this is not possible as missing catalog version leads to a `CatalogNotFoundException`.
--
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-24456: Sql. Unexpected SchemaNotFoundError when query does not access that schema [ignite-3]
Posted by "lowka (via GitHub)" <gi...@apache.org>.
lowka commented on code in PR #5210:
URL: https://github.com/apache/ignite-3/pull/5210#discussion_r1954256131
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/schema/IgniteSchemas.java:
##########
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.engine.schema;
+
+import org.apache.calcite.schema.SchemaPlus;
+
+/**
+ * Schema container.
+ */
+public final class IgniteSchemas {
+
+ private final SchemaPlus rootSchema;
+
+ private final int catalogVersion;
+
+ /**
+ * Constructor.
+ *
+ * @param rootSchema Root schema.
+ * @param catalogVersion Catalog version.
+ */
+ public IgniteSchemas(SchemaPlus rootSchema, int catalogVersion) {
+ this.rootSchema = rootSchema;
+ this.catalogVersion = catalogVersion;
+ }
+
+ /**
+ * Returns a {@link SchemaPlus} that contains all catalog schemas.
+ *
+ * @return Root schema.
+ */
+ public SchemaPlus root() {
+ return rootSchema;
+ }
+
+ /**
+ * Returns catalog version this schemas belong to.
Review Comment:
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