Map Cassandra INET to Trino IPADDRESS type#13068
Map Cassandra INET to Trino IPADDRESS type#13068ebyhr merged 3 commits intotrinodb:masterfrom chen-ni:issue-851-task-2
Conversation
|
Pls remove the first two commits (they are useless if the second one reverts the first one). |
|
Please do take some time to fill in the response about the question:
|
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypes.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java
Outdated
Show resolved
Hide resolved
...oduct-tests/src/main/java/io/trino/tests/product/cassandra/TestInsertIntoCassandraTable.java
Outdated
Show resolved
Hide resolved
...oduct-tests/src/main/java/io/trino/tests/product/cassandra/TestInsertIntoCassandraTable.java
Outdated
Show resolved
Hide resolved
ebyhr
left a comment
There was a problem hiding this comment.
Please update "Data types" in cassandra.rst. Thanks for your contribution.
@ebyhr Thanks for the helpful suggestion! To move away from the static type mapping pattern, the simplest approach I can think of is just to make those fields non-static, initialize them from the constructor (and maybe add some builders later to allow dynamically getting type mappings) and access those type mappings through an instance of Is this what's expected? Or is some bigger change expected? |
ebyhr
left a comment
There was a problem hiding this comment.
Is this what's expected? Or is some bigger change expected?
I expect larger change. We shouldn't initialize a CassandraTypes variable from CassandraMetadata.
@ebyhr I agree. I'm trying to figure out how to avoid it, but it seems a little difficult. The biggest problem is how to get a As for the refactoring you suggested earlier:
I'm still not sure which kind of refactoring is expected. I'll keep trying, but it would be great if you could shed some light on it when possible :) Anyway, now that the tests pass, I'll keep refactoring until it's acceptable. |
|
@ebyhr I just removed the static |
There was a problem hiding this comment.
nit: separate commit CassandraType.toCassandraType -> toCassandraType
There was a problem hiding this comment.
@findinpath Sorry, I don't quite understand here. What do we need to put in the separate commit? A change to static import?
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraConnectorTest.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/trino/plugin/cassandra/util/TestCassandraClusteringPredicatesExtractor.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/trino/plugin/cassandra/util/TestCassandraClusteringPredicatesExtractor.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraType.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeMapping.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraPageSink.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraSession.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/trino/plugin/cassandra/util/TestCassandraClusteringPredicatesExtractor.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/trino/plugin/cassandra/util/TestCassandraClusteringPredicatesExtractor.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraPageSinkProvider.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/main/java/io/trino/plugin/cassandra/CassandraTypeManager.java
Outdated
Show resolved
Hide resolved
plugin/trino-cassandra/src/test/java/io/trino/plugin/cassandra/TestCassandraTypeMapping.java
Outdated
Show resolved
Hide resolved
|
Merged, thanks! |
|
@ebyhr Sorry, just realized I didn't remove the outdated static It was indeed removed in the original commit but the change must have been lost while resolving a conflict during one of the fixes later. Should I create a simple PR to remove it or it's fine to leave it like this for a while? P.S. Thanks for the helpful code reviews and refactoring example :) |
|
@chen-ni You can send another PR. Thanks for finding that. |
Description
An improvement in type mapping. We used to map Cassandra
INETtype to TrinoVARCHAR. It would be better to map it to TrinoIPADDRESS.Due to the fact that
IpAddressTypeis not located in io.trino.spi.type, we have to usetypeManager().getType()to get the type reference (please refer to this discussion).The Cassandra connector.
By mapping the Cassandra
INETto TrinoIPADDRESStype, when readingINETdata in Cassandra, we can apply IP Address Functions without the need for casting.Related issues, pull requests, and links
Fix #851.
I've referred to the 2 following PRs:
Documentation
( ) No documentation is needed.
(x) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
( ) Release notes entries required with the following suggested text: