cassandra system.schema_列插入到其他表中并进行修改

cassandra system.schema_列插入到其他表中并进行修改,cassandra,datastax,cql3,Cassandra,Datastax,Cql3,我有以下选择: select * from system.schema_columns where keyspace_name = 'automotive' and columnfamily_name = 'cars'; 我想将此返回的数据插入到另一个表中,并进行一些修改: -我想插入列的数据类型 -删除诸如created_at、created_by等审核列 在my sql中,我们可以通过以下方式实现: insert into formUtil(table_name, column_name,

我有以下选择:

select * from system.schema_columns where keyspace_name = 'automotive' and columnfamily_name = 'cars';
我想将此返回的数据插入到另一个表中,并进行一些修改:

-我想插入列的数据类型

-删除诸如created_at、created_by等审核列

在my sql中,我们可以通过以下方式实现:

insert into formUtil(table_name, column_name, ordinal_position, is_nullable, data_type)
SELECT 
    col.table_name, 
    col.column_name, 
    col.ordinal_position, 
    case when col.is_nullable = 'YES' then 1 else 0 end, 
    col.data_type
from 
    information_schema.COLUMNS col 
where 
    col.table_schema = 'i2cwac' and
    col.column_name not in ('id','modifiedAt','modifiedBy','createdAt','createdBy') and
    col.table_name = 'users';

我们如何在卡桑德拉做到这一点?

您可以使用Spark实现这一点

import java.nio.ByteBuffer;
import com.datastax.spark.connector._;

case class SchemaColumns(keyspaceName: String, tableName: String, clusteringOrder: String, columnNameBytes: ByteBuffer, kind: String, position: Int, type: String)
case class AnotherTable(keyspaceName: String, tableName: String, type: String)

sc.cassandraTable[SchemaColumns]("system", "schema_columns")
    .map(schemaColumns -> AnotherTable(schemaColumns.keyspaceName,schemaColumns.tableName, schemaColumns.type)
    .saveToCassandra("my_keyspace","another_table")

谢谢,但我不想用spark。只有cql。如果列是分区键、集群键或常规键,则返回schema_columns中的type列。我想获取该列的数据类型,比如文本、列表、uuit、timestamp、varchar以及其他内容