[ 
https://issues.apache.org/jira/browse/CASSANDRA-16378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17463322#comment-17463322
 ] 

Tibor Repasi commented on CASSANDRA-16378:
------------------------------------------

Help needed. I didn't found any example to add a collection type to a virtual 
table.

My approach to add a column of CQL type {{map<text,text>}} to the clients table 
is like:
{code:java}
    ClientsTable(String keyspace)
    {
        super(TableMetadata.builder(keyspace, "clients")
...
           .addRegularColumn(CLIENT_OPTIONS, 
MapType.getInstance(UTF8Type.instance, UTF8Type.instance, true))
...
{code}
filling it with data:
{code:java}
    public DataSet data()
...
        result.row(remoteAddress.getAddress(), remoteAddress.getPort())
...
           .column(CLIENT_OPTIONS, client.clientOptions())
{code}
where ConnectedClient#clientOptions() is returning a {{Map<String, String>}}.

Unfortunately, querying that column ends up with
{code:java}
ERROR [Native-Transport-Requests-1] 2021-12-21 16:26:29,828 
ExceptionHandlers.java:230 - Unexpected exception during request; channel = 
[id: 0x13828495, L:/127.0.0.1:9042 - R:localhost/127.0.0.1:64184]
java.lang.AssertionError: Column system_views.clients(client_options: 
org.apache.cassandra.db.marshal.MapType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type))
 isComplex: true with cellpath: null
        at org.apache.cassandra.db.rows.BufferCell.<init>(BufferCell.java:48)
        at org.apache.cassandra.db.rows.BufferCell.live(BufferCell.java:63)
        at org.apache.cassandra.db.rows.BufferCell.live(BufferCell.java:58)
        at 
org.apache.cassandra.db.virtual.SimpleDataSet$Row.lambda$toTableRow$0(SimpleDataSet.java:193)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at 
org.apache.cassandra.db.virtual.SimpleDataSet$Row.toTableRow(SimpleDataSet.java:189)
        at 
org.apache.cassandra.db.virtual.SimpleDataSet$SimplePartition$1.computeNext(SimpleDataSet.java:155)
        at 
org.apache.cassandra.db.virtual.SimpleDataSet$SimplePartition$1.computeNext(SimpleDataSet.java:148)
{code}

What is issue I can't see?

> Expose application_name and application_version in virtual table 
> system_views.clients
> -------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-16378
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-16378
>             Project: Cassandra
>          Issue Type: Improvement
>          Components: Feature/Virtual Tables
>            Reporter: Tibor Repasi
>            Assignee: Tibor Repasi
>            Priority: Normal
>              Labels: AdventCalendar2021, gsoc2021, lhf, mentor
>
> Recent java-driver's 
> [com.datastax.oss.driver.api.core.session.SessionBuilder|https://docs.datastax.com/en/drivers/java/4.9/com/datastax/oss/driver/api/core/session/SessionBuilder.html]
>  respects properties 
> [ApplicationName|https://docs.datastax.com/en/drivers/java/4.9/com/datastax/oss/driver/api/core/session/SessionBuilder.html#withApplicationName-java.lang.String-]
>  and 
> [ApplicationVersion|https://docs.datastax.com/en/drivers/java/4.9/com/datastax/oss/driver/api/core/session/SessionBuilder.html#withApplicationVersion-java.lang.String-].
> It would be helpful to exposed this information via virtual table 
> {{system_views.clients}} and with {{nodetool clientstats}}.
> +Additional information for newcomers:+
> The drivers can send as part of the {{STARTUP MESSAGE}} the 
> {{APPLICATION_NAME}} and {{APPLICATION_VERSION}} options. To new volatile 
> fields {{applicationName}} and {{applicationVersion}} need to be added to 
> {{ClientState}} in a similar way to {{driverName}} and {{driverVersion}}.
> The  {{APPLICATION_NAME}} and {{APPLICATION_VERSION}} optionsneed to be 
> retrieved in {{StartupMessage#execute}} and passed to the {{ClientState}}. 
> The new {{application_name}} and {{application_version}} columns need to be 
> added to the {{system_views.clients}} represented by the {{ClientsTable}} 
> class. The data then need to be retrieved from the {{ClientState}} through 
> {{ConnectedClient}}.
> Some unit tests similat to {{SettingsTableTest}} should be added. 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to