Can we refer a Cassandra table with multiple names ?
Say I have created a table with keyspacename.maintable
Now I want to refer keyspacename.maintable table as
keyspacename.alternatename1,
keyspacename.alternatename2,
keyspacename.alternatename3.
Is it possible ?
Hope Cassandra doesn't have this feature of alais, but this could be achieved using Cassandra datastax driver, cqlengine object mapper. Using object mapper, you can access a table as object with different object names.
Related
I know I can use a custom dialect for having a correct mapping between my db and spark but how can I create a custom table schema with specific field data types and lengths when I use spark's jdbc.write options? I would like to have granular control over my table schemas when I load a table from spark.
There is a minimal flexibility for writes, implemented by
SPARK-10101 - Spark JDBC writer mapping String to TEXT or VARCHAR
SPARK-10849 - Allow user to specify database column type for data frame fields when writing data to jdbc data sources
but if you want
to have granular control over my table schemas when I load a table from spark.
you might have to implement your own JdbcDialect. It is internal developer API and as far as I can tell it is not plugable so you may need customized Spark binaries (it might be possible to registerDialect but I haven't tried this).
https://spark.apache.org/docs/latest/sql-data-sources-jdbc.html
You can use the createTableColumnTypes option.
Here is the example from the documentation.
Specifying create table column data types on write
jdbcDF.write \
.option("createTableColumnTypes", "name CHAR(64), comments VARCHAR(1024)") \
.jdbc("jdbc:postgresql:dbserver", "schema.tablename",
properties={"user": "username", "password": "password"})
I am looking into the Spring Data provider for Cassandra and don't see a way to specify a column as static when a table includes clustering keys. Am I missing something?
There's no CQL generation support for static columns. Do you want to file an issue at https://jira.spring.io/browse/DATACASS?
For now, create the CQL of this table yourself.
I'm in making a gui client for Cassandra.
How to get details of existing key-spaces, column family, column details in Cassandra?
Is there any meta data storing tables in cassandra?
All of the metadata about Cassandra is in the system keyspace.
A better solution might be to use the DataStax JavaDriver to connect to the Cluster, then use the MetaData available there so you don't have to re-invent the wheel.
com.datastax.driver.core.Cluster c = com.datastax.driver.core.Cluster.builder()
.addContactPoint(cluster.getContactPoint()).withPort(cluster.getRpcPort()).build();
c.connect();
Metadata md = c.getMetadata();
List<KeyspaceMetadata> keyspaces = md.getKeyspaces();
c.close();
There are other methods on the Metadata object to get just about anything you need from the cluster configuration.
I'm trying to leverage a specific feature of Apache Cassandra CQL3, which is partition and clustering keys for tables which are created with compact storage option.
For Eg.
CREATE TABLE EMPLOYEE(id uuid, name text, field text, value text, primary key(id, name , field )) with compact storage;
I've created the table via CQL3 and i;m able to insert rows successfully using the Hector API.
But I couldn't find right set of options in the hector api to create the table itself as i require.
To elaborate a little bit more:
In ColumnFamilyDefinition.java i couldnt see an option for setting storage option (as compact storage) and In ColumnDefinition.java, i couldnt find the option to say that this column is part of the Partition and Clustering Keys
Could you please give me an idea of whether i can use Hector for this (i.e. Creating table) or not and if i can do that, what are the options that i need to provide?
If you are not tied to Hector, you could look into the DataStax Java Driver which was created to use CQL3 and Cassandra's binary protocol.
I am using hector-core1.0-5 from prettyprint for connecting to cassandra. Using this API I am able to create the keyspace. But I am unable to find the method which configures the "caching" property of column family. So as default it assigns "KEYS_ONLY" as "caching" value for all column families created. I wan to change this property value to "ALL" so that I can use both the key cache and row cache in cassandra.My cassandra version1.2.0. Anyone help me in finding the way to alter the "caching" property at the time a keyspace is created.
There is not support for get or set caching in ColumnFamilyDefinition interface. Hector community has to patch the code.
No idea about Hector as such. But we are using Playorm for Cassandra and it uses Caches like hibernate. Read more information at http://buffalosw.com/wiki/Caching-in-Playorm/.