[
https://issues.apache.org/jira/browse/CASSANDRA-20161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17923686#comment-17923686
]
Stefan Miklosovic edited comment on CASSANDRA-20161 at 2/4/25 12:49 PM:
------------------------------------------------------------------------
Looks WAY better but we should cover corner-cases like this:
{code:java}
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key =
'1:000000010000000200000003';
keyspace_name | table_name | token_value | key
| size_estimate | sstables
---------------+------------+---------------------+----------------------------+---------------+----------
ks | tb5 | 9184557612365013151 | 1:000000010000000200000003
| 30 | 1
(1 rows)
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key = '1:[1,2,3]';
NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host:
127.0.0.1:9042 datacenter1>: <Error from server: code=0000 [Server error]
message="org.apache.cassandra.serializers.MarshalException: cannot parse
'[1,2,3]' as hex bytes">})
{code}
I am not saying we should somehow change the key by which we query
(1:000000010000000200000003), I think that is just not necessary.
I am say that we should fail somehow "meaningfully" so we do not throw
exceptions visible in server side
{code:java}
ERROR [Native-Transport-Requests-1] 2025-02-04 13:40:54,024
QueryMessage.java:130 - Unexpected error during query
org.apache.cassandra.serializers.MarshalException: cannot parse '[1,2,3]' as
hex bytes
at
org.apache.cassandra.db.marshal.VectorType.fromString(VectorType.java:283)
at
org.apache.cassandra.db.marshal.AbstractCompositeType.fromString(AbstractCompositeType.java:248)
at
org.apache.cassandra.db.virtual.PartitionKeyStatsTable.getBounds(PartitionKeyStatsTable.java:318)
at
org.apache.cassandra.db.virtual.PartitionKeyStatsTable.select(PartitionKeyStatsTable.java:169)
at
org.apache.cassandra.db.SinglePartitionReadCommand$VirtualTableSinglePartitionReadCommand.executeLocally(SinglePartitionReadCommand.java:1398)
at
org.apache.cassandra.db.AbstractReadQuery.executeInternal(AbstractReadQuery.java:65)
at org.apache.cassandra.db.ReadCommand.executeInternal(ReadCommand.java:97)
at
org.apache.cassandra.db.SinglePartitionReadCommand$VirtualTableSinglePartitionReadCommand.execute(SinglePartitionReadCommand.java:1391)
at
org.apache.cassandra.service.pager.AbstractQueryPager.fetchPage(AbstractQueryPager.java:76)
at
org.apache.cassandra.service.pager.SinglePartitionPager.fetchPage(SinglePartitionPager.java:32)
at
org.apache.cassandra.cql3.statements.SelectStatement$Pager$NormalPager.fetchPage(SelectStatement.java:493)
at
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:550)
{code}
It would be enough to do at little as this:
https://github.com/apache/cassandra/pull/3857/commits/21fa40f6138b9c30f1854f1c17e0902c6e4f18c4
To achieve this, without any errors on the server side:
{code}
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key = '1:[1,2,3]';
InvalidRequest: Error from server: code=2200 [Invalid query] message="cannot
parse '[1,2,3]' as hex bytes"
{code}
was (Author: smiklosovic):
Looks WAY better but we should cover corner-cases like this:
{code:java}
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key =
'1:000000010000000200000003';
keyspace_name | table_name | token_value | key
| size_estimate | sstables
---------------+------------+---------------------+----------------------------+---------------+----------
ks | tb5 | 9184557612365013151 | 1:000000010000000200000003
| 30 | 1(1 rows)
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key = '1:[1,2,3]';
NoHostAvailable: ('Unable to complete the operation against any hosts', {<Host:
127.0.0.1:9042 datacenter1>: <Error from server: code=0000 [Server error]
message="org.apache.cassandra.serializers.MarshalException: cannot parse
'[1,2,3]' as hex bytes">})
{code}
I am not saying we should somehow change the key by which we query
(1:000000010000000200000003), I think that is just not necessary.
I am say that we should fail somehow "meaningfully" so we do not throw
exceptions visible in server side
{code:java}
ERROR [Native-Transport-Requests-1] 2025-02-04 13:40:54,024
QueryMessage.java:130 - Unexpected error during query
org.apache.cassandra.serializers.MarshalException: cannot parse '[1,2,3]' as
hex bytes
at
org.apache.cassandra.db.marshal.VectorType.fromString(VectorType.java:283)
at
org.apache.cassandra.db.marshal.AbstractCompositeType.fromString(AbstractCompositeType.java:248)
at
org.apache.cassandra.db.virtual.PartitionKeyStatsTable.getBounds(PartitionKeyStatsTable.java:318)
at
org.apache.cassandra.db.virtual.PartitionKeyStatsTable.select(PartitionKeyStatsTable.java:169)
at
org.apache.cassandra.db.SinglePartitionReadCommand$VirtualTableSinglePartitionReadCommand.executeLocally(SinglePartitionReadCommand.java:1398)
at
org.apache.cassandra.db.AbstractReadQuery.executeInternal(AbstractReadQuery.java:65)
at org.apache.cassandra.db.ReadCommand.executeInternal(ReadCommand.java:97)
at
org.apache.cassandra.db.SinglePartitionReadCommand$VirtualTableSinglePartitionReadCommand.execute(SinglePartitionReadCommand.java:1391)
at
org.apache.cassandra.service.pager.AbstractQueryPager.fetchPage(AbstractQueryPager.java:76)
at
org.apache.cassandra.service.pager.SinglePartitionPager.fetchPage(SinglePartitionPager.java:32)
at
org.apache.cassandra.cql3.statements.SelectStatement$Pager$NormalPager.fetchPage(SelectStatement.java:493)
at
org.apache.cassandra.cql3.statements.SelectStatement.execute(SelectStatement.java:550)
{code}
It would be enough to do at little as this:
https://github.com/apache/cassandra/pull/3857/commits/21fa40f6138b9c30f1854f1c17e0902c6e4f18c4
To achieve this, without any errors on the server side:
{code}
cassandra@cqlsh> select * from system_views.partition_key_statistics where
keyspace_name = 'ks' and table_name = 'tb5' and key = '1:[1,2,3]';
InvalidRequest: Error from server: code=2200 [Invalid query] message="cannot
parse '[1,2,3]' as hex bytes"
{code}
> Virtual table to query partition keys in a table
> ------------------------------------------------
>
> Key: CASSANDRA-20161
> URL: https://issues.apache.org/jira/browse/CASSANDRA-20161
> Project: Apache Cassandra
> Issue Type: New Feature
> Components: Feature/Virtual Tables
> Reporter: Chris Lohfink
> Assignee: Chris Lohfink
> Priority: Low
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> Introduce a new virtual table, {{{}PrimaryIdTable{}}}, to allow users to
> query partition keys and related metadata for a specific table within a
> keyspace. This feature provides insights into SSTable-level details, such as
> token values, size estimates, and SSTable counts, without requiring expensive
> disk-based operations.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]