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

Introduce Object Type handling in SQL [HZ-2312] #24356

Merged
merged 23 commits into from
Apr 27, 2023

Conversation

TomaszGaweda
Copy link
Contributor

@TomaszGaweda TomaszGaweda commented Apr 24, 2023

  1. Connector as for now won't define isStreaming method, but this will be a property of HazelcastTable.
  2. Connector should decide on streaming = true|false based on the objectType
  3. SqlConnector was refactored to return DTO of Mapping instead of most of fields as arguments.

Note:
This PR replaces:

create mapping myMongo 
type MongoStream (...)

with

create mapping myMongo
type Mongo object type ChangeStream

Mongo is a new beta feature in 5.3, so it's not a separate thing for RNs, but docs must be updated accordingly.

Jira: HZ-2312
Fixes: #24302

Breaking changes (list specific methods/types/messages):

  • API - SqlConnector

Checklist:

  • Labels (Team:, Type:, Source:, Module:) and Milestone set
  • Label Add to Release Notes or Not Release Notes content set
  • Request reviewers if possible
  • [-] Send backports/forwardports if fix needs to be applied to past/future releases
  • New public APIs have @Nonnull/@Nullable annotations
  • New public APIs have @since tags in Javadoc

@TomaszGaweda TomaszGaweda self-assigned this Apr 24, 2023
@TomaszGaweda TomaszGaweda added the SQL-only Use when changes are only in hazelcast-sql module label Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@TomaszGaweda TomaszGaweda added this to the 5.3.0 milestone Apr 24, 2023
@TomaszGaweda TomaszGaweda added Team: Integration and removed SQL-only Use when changes are only in hazelcast-sql module labels Apr 24, 2023
@TomaszGaweda TomaszGaweda changed the title WIP ObjectType WIP ObjectType [HZ-2312] Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 24, 2023
@TomaszGaweda
Copy link
Contributor Author

run-lab-run

Copy link
Contributor

@frant-hartm frant-hartm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving.

@Fly-Style @k-jamroz Please check the getAllDataConnectionNameWithTypes method as it returns row as Object[] inside which there is an ArrrayList, with type JSON.

No idea if that is correct or not.

public ViewTable(String schemaName, String viewName, String viewQuery, TableStatistics statistics) {
super(schemaName, viewName, null, statistics);
public ViewTable(String schemaName, String viewName, String viewQuery, TableStatistics statistics, boolean streaming) {
super(schemaName, viewName, null, statistics, "View", streaming);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I am coming to the conclusion we can avoid defining 'streaming' view here and do it later based on OptUtils.isUnbounded(viewRel) in initFields method. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically always pass e.g. false and set "real" value in initFields? I'm not that familiar with SQL yet, but if initFields is mandatory, then it makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.getAllDataConnectionEntries(dataConnectionService, dataConnectionCatalog.getDataConnectionStorage())
.stream()
.map(DataConnectionCatalogEntry::name);
.getAllDataConnectionNameWithTypes(dataConnectionService)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You changed SHOW DATA CONNECTIONS behavior, is it intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Correct me if I'm wrong, but semantics will be the same - all the same connections will be shown. The only difference is that for SHOW DATA CONNECTIONS we add additional column to provide user an information about supported object types. Idea is from this message: https://hazelcast.slack.com/archives/CJZ745RRT/p1681908716511929?thread_ts=1681849114.133969&cid=CJZ745RRT

Copy link
Contributor

@k-jamroz k-jamroz Apr 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes #24415, OBJECT TYPE without CONNECTION TYPE does not make much sense.
In slack thread we dissussed adding it to SHOW RESOURCES not to SHOW DATA CONNECTIONS

plan.getShowTarget() == ShowStatementTarget.DATACONNECTIONS
? new SqlRowMetadata(asList(
new SqlColumnMetadata("name", VARCHAR, false),
new SqlColumnMetadata("types", JSON, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why JSON specifically? JSON is just a wrapper type anyway, its not like its going to provide much utility on clients or is there actually a benefit to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be parseable by the JDBC client

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this causes #24415, OBJECT TYPE without CONNECTION TYPE does not make much sense

@@ -82,6 +88,7 @@ public void writeData(ObjectDataOutput out) throws IOException {
}
SerializationUtil.writeList(viewColumnNames, out);
SerializationUtil.writeList(viewColumnTypes, out);
out.writeBoolean(streaming);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a version guard here actually? E.g. in.getVersion().isGreaterOrEqual(Versions.V5_3).. And it will most likely be a good idea to test this in a rolling upgrade setup just to be sure I guess (probably enough to just create some schema objects in 5.2 node and join a 5.3, verify that it has the schema objects and then drop the 5.2 member and verify that 5.3's schema is working as expected).

In a rolling upgrade these schema objects will still be transferred because they're in a regular IMap. We might need some mechanism post 5.2 -> 5.3 upgrade for handling that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this field is no longer used if I initialize ViewTable's streaming property based on OptUtils.isUnbounded. I will remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the field was not removed from serialized form

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hz-devops-test
Copy link

The job Hazelcast-pr-builder of your PR failed. (Hazelcast internal details: build log, artifacts).
Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log file

@hz-devops-test
Copy link

The job Hazelcast-pr-compiler of your PR failed. (Hazelcast internal details: build log, artifacts).
Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log file

@hazelcast hazelcast deleted a comment from hz-devops-test Apr 26, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 26, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 26, 2023
@hazelcast hazelcast deleted a comment from hz-devops-test Apr 26, 2023
@TomaszGaweda TomaszGaweda removed the request for review from k-jamroz April 26, 2023 13:21
@frant-hartm frant-hartm enabled auto-merge (squash) April 27, 2023 12:26
@frant-hartm frant-hartm merged commit 64d6863 into hazelcast:master Apr 27, 2023
8 checks passed
@@ -31,7 +31,7 @@ public final class BadTable extends Table {
private final Throwable cause;

public BadTable(String schemaName, String sqlName, Throwable cause) {
super(schemaName, sqlName, Collections.emptyList(), new ConstantTableStatistics(0));
super(schemaName, sqlName, Collections.emptyList(), new ConstantTableStatistics(0), "Bad", false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isStreaming() should throw, we could pass original object type of bad mapping

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nonnull
@Override
public Collection<String> resourceTypes() {
return Collections.singleton("IMap");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use constants so it is defined in single place

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k-jamroz added a commit that referenced this pull request May 3, 2023
Follow-up to #24356

Changes:
- Remove View.streaming field completely, Ensure that isStreaming for
view is determined
- Use original object type for bad table
- Update SHOW DATA CONNECTIONS description in TDD
- Use constants for object type
- Refactor SqlMappingContext and simplify
SqlConnector.resolveAndValidateFields
- Resource type is case-insensitive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to create streaming type mappings using 'Mongo' DATA CONNECTION [HZ-2312]
6 participants