Cassandra – Drop Keyspace ”; Previous Next Dropping a Keyspace You can drop a KeySpace using the command DROP KEYSPACE. Given below is the syntax for dropping a KeySpace. Syntax DROP KEYSPACE <identifier> i.e. DROP KEYSPACE “KeySpace name” Example The following code deletes the keyspace tutorialspoint. cqlsh> DROP KEYSPACE tutorialspoint; Verification Verify the keyspaces using the command Describe and check whether the table is dropped as shown below. cqlsh> DESCRIBE keyspaces; system system_traces Since we have deleted the keyspace tutorialspoint, you will not find it in the keyspaces list. Dropping a Keyspace using Java API You can create a keyspace using the execute() method of Session class. Follow the steps given below to drop a keyspace using Java API. Step1: Create a Cluster Object First of all, create an instance of Cluster.builder class of com.datastax.driver.core package as shown below. //Creating Cluster.Builder object Cluster.Builder builder1 = Cluster.builder(); Add a contact point (IP address of the node) using the addContactPoint() method of Cluster.Builder object. This method returns Cluster.Builder. //Adding contact point to the Cluster.Builder object Cluster.Builder builder2 = build.addContactPoint( “127.0.0.1” ); Using the new builder object, create a cluster object. To do so, you have a method called build() in the Cluster.Builder class. The following code shows how to create a cluster object. //Building a cluster Cluster cluster = builder.build(); You can build a cluster object using a single line of code as shown below. Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); Step 2: Create a Session Object Create an instance of Session object using the connect() method of Cluster class as shown below. Session session = cluster.connect( ); This method creates a new session and initializes it. If you already have a keyspace, you can set it to the existing one by passing the keyspace name in string format to this method as shown below. Session session = cluster.connect(“ Your keyspace name”); Step 3: Execute Query You can execute CQL queries using the execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh. In the following example, we are deleting a keyspace named tp. You have to store the query in a string variable and pass it to the execute() method as shown below. String query = “DROP KEYSPACE tp; “; session.execute(query); Given below is the complete program to create and use a keyspace in Cassandra using Java API. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class Drop_KeySpace { public static void main(String args[]){ //Query String query = “Drop KEYSPACE tp”; //creating Cluster object Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); //Creating Session object Session session = cluster.connect(); //Executing the query session.execute(query); System.out.println(“Keyspace deleted”); } } Save the above program with the class name followed by .java, browse to the location where it is saved. Compile and execute the program as shown below. $javac Delete_KeySpace.java $java Delete_KeySpace Under normal conditions, it should produce the following output − Keyspace deleted Print Page Previous Next Advertisements ”;
Category: Big Data & Analytics
AWS Quicksight – AWS SDKs
AWS Quicksight – AWS SDKs ”; Previous Next You can use AWS Quicksight SDK’s to manage the following − User and group management Embedding dashboards Following shows a sample HTML code to be used to display an embedded dashboard − <!DOCTYPE html> <html> <head> <title>Sample Embed</title> <script type=”text/javascript” src=”https://unpkg.com/[email protected]/dist/quicksight-embedding-js-sdk.min.js”></script> <script type=”text/javascript”> function embedDashboard() { var containerDiv = document.getElementById(“dashboardContainer”); var params = { url: “https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/xxx-x-x-xx-x-x-x-x-x-x-x-xx-xx-x-xx”, container: containerDiv, parameters: { country: ”United States” }, height: “600px”, width: “800px” }; var dashboard = QuickSightEmbedding.embedDashboard(params); dashboard.on(”error”, function() {}); dashboard.on(”load”, function() {}); dashboard.setParameters({country: ”Canada”}); } </script> </head> <html> To use AWS SDK’s, you should be familiar with the following − JSON Web services HTTP requests One or more programming languages, such as JavaScript, Java, Python, or C#. Print Page Previous Next Advertisements ”;
Cassandra – Create Keyspace
Cassandra – Create Keyspace ”; Previous Next Creating a Keyspace using Cqlsh A keyspace in Cassandra is a namespace that defines data replication on nodes. A cluster contains one keyspace per node. Given below is the syntax for creating a keyspace using the statement CREATE KEYSPACE. Syntax CREATE KEYSPACE <identifier> WITH <properties> i.e. CREATE KEYSPACE “KeySpace Name” WITH replication = {”class”: ‘Strategy name’, ”replication_factor” : ‘No.Of replicas’}; CREATE KEYSPACE “KeySpace Name” WITH replication = {”class”: ‘Strategy name’, ”replication_factor” : ‘No.Of replicas’} AND durable_writes = ‘Boolean value’; The CREATE KEYSPACE statement has two properties: replication and durable_writes. Replication The replication option is to specify the Replica Placement strategy and the number of replicas wanted. The following table lists all the replica placement strategies. Strategy name Description Simple Strategy” Specifies a simple replication factor for the cluster. Network Topology Strategy Using this option, you can set the replication factor for each data-center independently. Old Network Topology Strategy This is a legacy replication strategy. Using this option, you can instruct Cassandra whether to use commitlog for updates on the current KeySpace. This option is not mandatory and by default, it is set to true. Example Given below is an example of creating a KeySpace. Here we are creating a KeySpace named TutorialsPoint. We are using the first replica placement strategy, i.e.., Simple Strategy. And we are choosing the replication factor to 1 replica. cqlsh.> CREATE KEYSPACE tutorialspoint WITH replication = {”class”:”SimpleStrategy”, ”replication_factor” : 3}; Verification You can verify whether the table is created or not using the command Describe. If you use this command over keyspaces, it will display all the keyspaces created as shown below. cqlsh> DESCRIBE keyspaces; tutorialspoint system system_traces Here you can observe the newly created KeySpace tutorialspoint. Durable_writes By default, the durable_writes properties of a table is set to true, however it can be set to false. You cannot set this property to simplex strategy. Example Given below is the example demonstrating the usage of durable writes property. cqlsh> CREATE KEYSPACE test … WITH REPLICATION = { ”class” : ”NetworkTopologyStrategy”, ”datacenter1” : 3 } … AND DURABLE_WRITES = false; Verification You can verify whether the durable_writes property of test KeySpace was set to false by querying the System Keyspace. This query gives you all the KeySpaces along with their properties. cqlsh> SELECT * FROM system_schema.keyspaces; keyspace_name | durable_writes | strategy_class | strategy_options —————-+—————-+——————————————————+—————————- test | False | org.apache.cassandra.locator.NetworkTopologyStrategy | {“datacenter1” : “3”} tutorialspoint | True | org.apache.cassandra.locator.SimpleStrategy | {“replication_factor” : “4”} system | True | org.apache.cassandra.locator.LocalStrategy | { } system_traces | True | org.apache.cassandra.locator.SimpleStrategy | {“replication_factor” : “2”} (4 rows) Here you can observe the durable_writes property of test KeySpace was set to false. Using a Keyspace You can use a created KeySpace using the keyword USE. Its syntax is as follows − Syntax:USE <identifier> Example In the following example, we are using the KeySpace tutorialspoint. cqlsh> USE tutorialspoint; cqlsh:tutorialspoint> Creating a Keyspace using Java API You can create a Keyspace using the execute() method of Session class. Follow the steps given below to create a keyspace using Java API. Step1: Create a Cluster Object First of all, create an instance of Cluster.builder class of com.datastax.driver.core package as shown below. //Creating Cluster.Builder object Cluster.Builder builder1 = Cluster.builder(); Add a contact point (IP address of the node) using addContactPoint() method of Cluster.Builder object. This method returns Cluster.Builder. //Adding contact point to the Cluster.Builder object Cluster.Builder builder2 = build.addContactPoint( “127.0.0.1” ); Using the new builder object, create a cluster object. To do so, you have a method called build() in the Cluster.Builder class. The following code shows how to create a cluster object. //Building a cluster Cluster cluster = builder.build(); You can build a cluster object in a single line of code as shown below. Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); Step 2: Create a Session Object Create an instance of Session object using the connect() method of Cluster class as shown below. Session session = cluster.connect( ); This method creates a new session and initializes it. If you already have a keyspace, you can set it to the existing one by passing the keyspace name in string format to this method as shown below. Session session = cluster.connect(“ Your keyspace name ” ); Step 3: Execute Query You can execute CQL queries using the execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh. In this example, we are creating a KeySpace named tp. We are using the first replica placement strategy, i.e., Simple Strategy, and we are choosing the replication factor to 1 replica. You have to store the query in a string variable and pass it to the execute() method as shown below. String query = “CREATE KEYSPACE tp WITH replication ” + “= {”class”:”SimpleStrategy”, ”replication_factor”:1}; “; session.execute(query); Step4 : Use the KeySpace You can use a created KeySpace using the execute() method as shown below. execute(“ USE tp ” ); Given below is the complete program to create and use a keyspace in Cassandra using Java API. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class Create_KeySpace { public static void main(String args[]){ //Query String query = “CREATE KEYSPACE tp WITH replication ” + “= {”class”:”SimpleStrategy”, ”replication_factor”:1};”; //creating Cluster object Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); //Creating Session object Session session = cluster.connect(); //Executing the query session.execute(query); //using the KeySpace session.execute(“USE tp”); System.out.println(“Keyspace created”); } } Save the above program with the class name followed by .java, browse to the location where it is saved. Compile and execute the program as shown below. $javac Create_KeySpace.java $java Create_KeySpace Under normal conditions, it will produce the following output − Keyspace created Print Page Previous Next Advertisements ”;
AWS Quicksight – Quick Guide
AWS Quicksight – Quick Guide ”; Previous Next AWS Quicksight – Overview AWS Quicksight is one of the most powerful Business Intelligence tools which allows you to create interactive dashboards within minutes to provide business insights into the organizations. There are number of visualizations or graphical formats available in which the dashboards can be created. The dashboards get automatically updated as the data is updated or scheduled. You can also embed the dashboard created in Quicksight to your web application. With the latest ML insights, also known as Machine Learning insights, Quicksight uses its inbuilt algorithms to find any kind of anomalies or peaks in the historical data. This helps to get prepared with the business requirements ahead of time based on these insights. Here is quick guide to get started with Quicksight. Below is official product description page from AWS − https://aws.amazon.com/quicksight/ You can also subscribe for an AWS trial account by filling the below mentioned information and click on Continue button. AWS Quicksight – Landing Page To access AWS Quicksight tool, you can open it directly by passing this URL in web browser or navigating to AWS Console → Services https://aws.amazon.com/quicksight/ Once you open this URL, on top right corner click on “Sign in to the Console”. You need to provide the below details to login to Quicksight tool − Account ID or alias IAM User name Password Once you login into Quicksight, you will see the below screen − As marked in the above image, Section A − “New Analysis” icon is used to create a new analysis. When you click on this, it will ask you to select any data set. You can also create a new data set as shown below − Section B − The “Manage data” icon will show all the data sets that have already been input to Quicksight. This option can be used to manage the dataset without creating any analysis. Section C − It shows various data sources you have already connected to. You can also connect to a new data source or upload a file. Section D − This section contains icon for already created analysis, published dashboards and tutorial videos explaining about Quicksight in detail. You can click on each tab to view them as below − All analysis Here, you can see all the existing analysis in AWS Quicksight account including report and dashboards. All dashboards This option shows only existing dashboards in AWS Quicksight account. Tutorial videos Other option to open Quicksight console is by navigating to AWS console using below URL − https://aws.amazon.com/console/ Once you login, you need to navigate to Services tab and search for Quicksight in search bar. If you have recently used Quicksight services in AWS account, it will be seen under History tab. AWS Quicksight – Using Data Sources AWS Quicksight accepts data from various sources. Once you click on “New Dataset” on the home page, it gives you options of all the data sources that can be used. Below are the sources containing the list of all internal and external sources − Let us go through connecting Quicksight with some of the most commonly used data sources − Uploading a file from system It allows you to input .csv, .tsv, .clf,.elf.xlsx and Json format files only. Once you select the file, Quicksight automatically recognizes the file and displays the data. When you click on Upload a File button, you need to provide the location of file which you want to use to create dataset. Using a file from S3 format The screen will appear as below. Under Data source name, you can enter the name to be displayed for the data set that would be created. Also you would require either uploading a manifest file from your local system or providing the S3 location of the manifest file. Manifest file is a json format file, which specifies the url/location of input files and their format. You can enter more than one input files, provided the format is same. Here is an example of a manifest file. The “URI” parameter used to pass the location of input file is S3. { “fileLocations”: [ { “URIs”: [ “url of first file”, “url of second file”, “url of 3rd file and so on” ] }, ], } “globalUploadSettings”: { “format”: “CSV”, “delimiter”: “,”, “textqualifier”: “””, “containsHeader”: “true” } The parameters passed in globalUploadSettings are the default ones. You can change these parameters as per your requirements. MySQL You need to enter the database information in the fields to connect to your database. Once it is connected to your database, you can import the data from it. Following information is required when you connect to any RDBMS database − DSN name Type of connection Database server name Port Database name User name Password Following RDBMS based data sources are supported in Quicksight − Amazon Athena Amazon Aurora Amazon Redshift Amazon Redshift Spectrum Amazon S3 Amazon S3 Analytics Apache Spark 2.0 or later MariaDB 10.0 or later Microsoft SQL Server 2012 or later MySQL 5.1 or later PostgreSQL 9.3.1 or later Presto 0.167 or later Snowflake Teradata 14.0 or later Athena Athena is the AWS tool to run queries on tables. You can choose any table from Athena or run a custom query on those tables and use the output of those queries in Quicksight. There are couple of steps to choose data source When you choose Athena, below screen appears. You can input any data source name which you want to give to your data source in Quicksight. Click on “Validate Connection”. Once the connection is validated, click on the “Create new source” button Now choose the table name from the dropdown. The dropdown will show the databases present in Athena which will further show tables in that database. Else you can click on “Use custom SQL” to run query on Athena tables. Once done, you can click on “Edit/Preview data” or “Visualize” to either edit your data or directly
Cassandra – Create Table
Cassandra – Create Table ”; Previous Next Creating a Table You can create a table using the command CREATE TABLE. Given below is the syntax for creating a table. Syntax CREATE (TABLE | COLUMNFAMILY) <tablename> (”<column-definition>” , ”<column-definition>”) (WITH <option> AND <option>) Defining a Column You can define a column as shown below. column name1 data type, column name2 data type, example: age int, name text Primary Key The primary key is a column that is used to uniquely identify a row. Therefore,defining a primary key is mandatory while creating a table. A primary key is made of one or more columns of a table. You can define a primary key of a table as shown below. CREATE TABLE tablename( column1 name datatype PRIMARYKEY, column2 name data type, column3 name data type. ) or CREATE TABLE tablename( column1 name datatype PRIMARYKEY, column2 name data type, column3 name data type, PRIMARY KEY (column1) ) Example Given below is an example to create a table in Cassandra using cqlsh. Here we are − Using the keyspace tutorialspoint Creating a table named emp It will have details such as employee name, id, city, salary, and phone number. Employee id is the primary key. cqlsh> USE tutorialspoint; cqlsh:tutorialspoint>; CREATE TABLE emp( emp_id int PRIMARY KEY, emp_name text, emp_city text, emp_sal varint, emp_phone varint ); Verification The select statement will give you the schema. Verify the table using the select statement as shown below. cqlsh:tutorialspoint> select * from emp; emp_id | emp_city | emp_name | emp_phone | emp_sal ——–+———-+———-+———–+——— (0 rows) Here you can observe the table created with the given columns. Since we have deleted the keyspace tutorialspoint, you will not find it in the keyspaces list. Creating a Table using Java API You can create a table using the execute() method of Session class. Follow the steps given below to create a table using Java API. Step1: Create a Cluster Object First of all, create an instance of the Cluster.builder class of com.datastax.driver.core package as shown below. //Creating Cluster.Builder object Cluster.Builder builder1 = Cluster.builder(); Add a contact point (IP address of the node) using the addContactPoint() method of Cluster.Builder object. This method returns Cluster.Builder. //Adding contact point to the Cluster.Builder object Cluster.Builder builder2 = build.addContactPoint( “127.0.0.1” ); Using the new builder object, create a cluster object. To do so, you have a method called build() in the Cluster.Builder class. The following code shows how to create a cluster object. //Building a cluster Cluster cluster = builder.build(); You can build a cluster object using a single line of code as shown below. Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); Step 2: Create a Session Object Create an instance of Session object using the connect() method of Cluster class as shown below. Session session = cluster.connect( ); This method creates a new session and initializes it. If you already have a keyspace, you can set it to the existing one by passing the keyspace name in string format to this method as shown below. Session session = cluster.connect(“ Your keyspace name ” ); Here we are using the keyspace named tp. Therefore, create the session object as shown below. Session session = cluster.connect(“ tp” ); Step 3: Execute Query You can execute CQL queries using the execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh. In the following example, we are creating a table named emp. You have to store the query in a string variable and pass it to the execute() method as shown below. //Query String query = “CREATE TABLE emp(emp_id int PRIMARY KEY, ” + “emp_name text, ” + “emp_city text, ” + “emp_sal varint, ” + “emp_phone varint );”; session.execute(query); Given below is the complete program to create and use a keyspace in Cassandra using Java API. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class Create_Table { public static void main(String args[]){ //Query String query = “CREATE TABLE emp(emp_id int PRIMARY KEY, ” + “emp_name text, ” + “emp_city text, ” + “emp_sal varint, ” + “emp_phone varint );”; //Creating Cluster object Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); //Creating Session object Session session = cluster.connect(“tp”); //Executing the query session.execute(query); System.out.println(“Table created”); } } Save the above program with the class name followed by .java, browse to the location where it is saved. Compile and execute the program as shown below. $javac Create_Table.java $java Create_Table Under normal conditions, it should produce the following output − Table created Print Page Previous Next Advertisements ”;
Cassandra – Update Data
Cassandra – Update Data ”; Previous Next Updating Data in a Table UPDATE is the command used to update data in a table. The following keywords are used while updating data in a table − Where − This clause is used to select the row to be updated. Set − Set the value using this keyword. Must − Includes all the columns composing the primary key. While updating rows, if a given row is unavailable, then UPDATE creates a fresh row. Given below is the syntax of UPDATE command − UPDATE <tablename> SET <column name> = <new value> <column name> = <value>…. WHERE <condition> Example Assume there is a table named emp. This table stores the details of employees of a certain company, and it has the following details − emp_id emp_name emp_city emp_phone emp_sal 1 ram Hyderabad 9848022338 50000 2 robin Hyderabad 9848022339 40000 3 rahman Chennai 9848022330 45000 Let us now update emp_city of robin to Delhi, and his salary to 50000. Given below is the query to perform the required updates. cqlsh:tutorialspoint> UPDATE emp SET emp_city=”Delhi”,emp_sal=50000 WHERE emp_id=2; Verification Use SELECT statement to verify whether the data has been updated or not. If you verify the emp table using SELECT statement, it will produce the following output. cqlsh:tutorialspoint> select * from emp; emp_id | emp_city | emp_name | emp_phone | emp_sal ——–+———–+———-+————+——— 1 | Hyderabad | ram | 9848022338 | 50000 2 | Delhi | robin | 9848022339 | 50000 3 | Chennai | rahman | 9848022330 | 45000 (3 rows) Here you can observe the table data has got updated. Updating Data using Java API You can update data in a table using the execute() method of Session class. Follow the steps given below to update data in a table using Java API. Step1: Create a Cluster Object Create an instance of Cluster.builder class of com.datastax.driver.core package as shown below. //Creating Cluster.Builder object Cluster.Builder builder1 = Cluster.builder(); Add a contact point (IP address of the node) using the addContactPoint() method of Cluster.Builder object. This method returns Cluster.Builder. //Adding contact point to the Cluster.Builder object Cluster.Builder builder2 = build.addContactPoint(“127.0.0.1”); Using the new builder object, create a cluster object. To do so, you have a method called build() in the Cluster.Builder class. Use the following code to create the cluster object. //Building a cluster Cluster cluster = builder.build(); You can build the cluster object using a single line of code as shown below. Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1″).build(); Step 2: Create a Session Object Create an instance of Session object using the connect() method of Cluster class as shown below. Session session = cluster.connect( ); This method creates a new session and initializes it. If you already have a keyspace, then you can set it to the existing one by passing the KeySpace name in string format to this method as shown below. Session session = cluster.connect(“ Your keyspace name”); Here we are using the KeySpace named tp. Therefore, create the session object as shown below. Session session = cluster.connect(“tp”); Step 3: Execute Query You can execute CQL queries using the execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh. In the following example, we are updating the emp table. You have to store the query in a string variable and pass it to the execute() method as shown below: String query = “ UPDATE emp SET emp_city=”Delhi”,emp_sal=50000 WHERE emp_id = 2;” ; Given below is the complete program to update data in a table using Java API. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class Update_Data { public static void main(String args[]){ //query String query = ” UPDATE emp SET emp_city=”Delhi”,emp_sal=50000″ //Creating Cluster object Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); //Creating Session object Session session = cluster.connect(“tp”); //Executing the query session.execute(query); System.out.println(“Data updated”); } } Save the above program with the class name followed by .java, browse to the location where it is saved. Compile and execute the program as shown below. $javac Update_Data.java $java Update_Data Under normal conditions, it should produce the following output − Data updated Print Page Previous Next Advertisements ”;
Cassandra – Drop Table
Cassandra – Drop Table ”; Previous Next Dropping a Table You can drop a table using the command Drop Table. Its syntax is as follows − Syntax DROP TABLE <tablename> Example The following code drops an existing table from a KeySpace. cqlsh:tutorialspoint> DROP TABLE emp; Verification Use the Describe command to verify whether the table is deleted or not. Since the emp table has been deleted, you will not find it in the column families list. cqlsh:tutorialspoint> DESCRIBE COLUMNFAMILIES; employee Deleting a Table using Java API You can delete a table using the execute() method of Session class. Follow the steps given below to delete a table using Java API. Step1: Create a Cluster Object First of all, create an instance of Cluster.builder class of com.datastax.driver.core package as shown below − //Creating Cluster.Builder object Cluster.Builder builder1 = Cluster.builder(); Add a contact point (IP address of the node) using addContactPoint() method of Cluster.Builder object. This method returns Cluster.Builder. //Adding contact point to the Cluster.Builder object Cluster.Builder builder2 = build.addContactPoint( “127.0.0.1” ); Using the new builder object, create a cluster object. To do so, you have a method called build() in the Cluster.Builder class. The following code shows how to create a cluster object. //Building a cluster Cluster cluster = builder.build(); You can build a cluster object using a single line of code as shown below. Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); Step 2: Create a Session Object Create an instance of Session object using the connect() method of Cluster class as shown below. Session session = cluster.connect( ); This method creates a new session and initializes it. If you already have a keyspace, you can set it to the existing one by passing the KeySpace name in string format to this method as shown below. Session session = cluster.connect(“Your keyspace name”); Here we are using the keyspace named tp. Therefore, create the session object as shown below. Session session = cluster.connect(“tp”); Step 3: Execute Query You can execute CQL queries using execute() method of Session class. Pass the query either in string format or as a Statement class object to the execute() method. Whatever you pass to this method in string format will be executed on the cqlsh. In the following example, we are deleting a table named emp. You have to store the query in a string variable and pass it to the execute() method as shown below. // Query String query = “DROP TABLE emp1;”; session.execute(query); Given below is the complete program to drop a table in Cassandra using Java API. import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Session; public class Drop_Table { public static void main(String args[]){ //Query String query = “DROP TABLE emp1;”; Cluster cluster = Cluster.builder().addContactPoint(“127.0.0.1”).build(); //Creating Session object Session session = cluster.connect(“tp”); //Executing the query session.execute(query); System.out.println(“Table dropped”); } } Save the above program with the class name followed by .java, browse to the location where it is saved. Compile and execute the program as shown below. $javac Drop_Table.java $java Drop_Table Under normal conditions, it should produce the following output − Table dropped Print Page Previous Next Advertisements ”;
Cassandra – Cqlsh
Cassandra – Cqlsh This chapter introduces the Cassandra query language shell and explains how to use its commands. By default, Cassandra provides a prompt Cassandra query language shell (cqlsh) that allows users to communicate with it. Using this shell, you can execute Cassandra Query Language (CQL). Using cqlsh, you can define a schema, insert data, and execute a query. Starting cqlsh Start cqlsh using the command cqlsh as shown below. It gives the Cassandra cqlsh prompt as output. [hadoop@linux bin]$ cqlsh Connected to Test Cluster at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3] Use HELP for help. cqlsh> Cqlsh − As discussed above, this command is used to start the cqlsh prompt. In addition, it supports a few more options as well. The following table explains all the options of cqlsh and their usage. Options Usage cqlsh –help Shows help topics about the options of cqlsh commands. cqlsh –version Provides the version of the cqlsh you are using. cqlsh –color Directs the shell to use colored output. cqlsh –debug Shows additional debugging information. cqlsh –execute cql_statement Directs the shell to accept and execute a CQL command. cqlsh –file= “file name” If you use this option, Cassandra executes the command in the given file and exits. cqlsh –no-color Directs Cassandra not to use colored output. cqlsh -u “user name” Using this option, you can authenticate a user. The default user name is: cassandra. cqlsh-p “pass word” Using this option, you can authenticate a user with a password. The default password is: cassandra. Cqlsh Commands Cqlsh has a few commands that allow users to interact with it. The commands are listed below. Documented Shell Commands Given below are the Cqlsh documented shell commands. These are the commands used to perform tasks such as displaying help topics, exit from cqlsh, describe,etc. HELP − Displays help topics for all cqlsh commands. CAPTURE − Captures the output of a command and adds it to a file. CONSISTENCY − Shows the current consistency level, or sets a new consistency level. COPY − Copies data to and from Cassandra. DESCRIBE − Describes the current cluster of Cassandra and its objects. EXPAND − Expands the output of a query vertically. EXIT − Using this command, you can terminate cqlsh. PAGING − Enables or disables query paging. SHOW − Displays the details of current cqlsh session such as Cassandra version, host, or data type assumptions. SOURCE − Executes a file that contains CQL statements. TRACING − Enables or disables request tracing. CQL Data Definition Commands CREATE KEYSPACE − Creates a KeySpace in Cassandra. USE − Connects to a created KeySpace. ALTER KEYSPACE − Changes the properties of a KeySpace. DROP KEYSPACE − Removes a KeySpace CREATE TABLE − Creates a table in a KeySpace. ALTER TABLE − Modifies the column properties of a table. DROP TABLE − Removes a table. TRUNCATE − Removes all the data from a table. CREATE INDEX − Defines a new index on a single column of a table. DROP INDEX − Deletes a named index. CQL Data Manipulation Commands INSERT − Adds columns for a row in a table. UPDATE − Updates a column of a row. DELETE − Deletes data from a table. BATCH − Executes multiple DML statements at once. CQL Clauses SELECT − This clause reads data from a table WHERE − The where clause is used along with select to read a specific data. ORDERBY − The orderby clause is used along with select to read a specific data in a specific order. Print Page Previous Next Advertisements ”;
Using Filters to a Visual
AWS Quicksight – Using Filters to a Visual ”; Previous Next Quicksight allows you to add filters to the visual being created. You have the option to apply filter to only a single visual under any analysis or all the visuals. To add filter, click on “Filter” icon on the left tab. It will show existing filter if there is any or filter can be created as per the requirement. In the below example, we don’t have any existing filters, so it gave an option to “Create one” On clicking create one, you can create filter. This allows you to choose if you want to add filter to just one or all the visuals. It also allows you to choose the field on which you want to apply filter. In the above example, we have added a filter on “Date of Birth” field on input dataset and specified a Date. Now, the visual contains the average tenure of employees under different job level and job family but only including employees whose Date of Birth is after 1980-01-01. Print Page Previous Next Advertisements ”;
AWS Quicksight – Useful Resources ”; Previous Next The following resources contain additional information on AWS Quicksight. Please use them to get more in-depth knowledge on this. Useful Links on AWS Quicksight Useful Video Courses Serverless Development With AWS Lambda And NodeJS 45 Lectures 7.5 hours Eduonix Learning Solutions More Detail Amazon (AWS) QuickSight, Glue, Athena & S3 Fundamentals 25 Lectures 3 hours Syed Raza More Detail AWS with Python Course 17 Lectures 1 hours Pranjal Srivastava More Detail Learn Analytics with AWS Athena and Quicksight 12 Lectures 47 mins Pranjal Srivastava More Detail Learn Machine Learning and Big Data Analytics with AWS 47 Lectures 4 hours Pranjal Srivastava More Detail AWS CodePipeline Videocourse: The Beginners Edition 19 Lectures 47 mins Pedro Planas More Detail Print Page Previous Next Advertisements ”;