Reputation:
The CTAS commans is: CREATE TABLE new_table_name AS <query>;
However, before creating table I have to create schema. I can't do it, moreover I can't use existing schema because for each installed yet schema I get error:
schema cp is immutable
. Hence solution is create new schema. The problem is that I can't find any example of this command.
Upvotes: 1
Views: 4601
Reputation: 1
You need to use dfs or any other storage plugin which uses local file system.
eg : create table dfs.test.temp_count
(user_count) as select t1.data as userParams from s3device.<File-Path>
t1 limit 1
Upvotes: 0
Reputation: 13753
Using CTAS, as per the docs you can only create new tables in workspaces. You cannot create tables in other storage plugins such as Hive and HBase.
You can store table data in one of three formats:
Steps to create table using CTAS:
Set store.format
:
alter session set `store.format`='json';
set location at which table (better to call file) is created:
Go to dfs plugin: http://localhost:8047/storage/dfs
In "workspaces", add writable (mutable) workspace. Eg:
"tmp": {
"location": "/tmp",
"writable": true,
}
do notice "writable": true
Use workspace:
use dfs.tmp;
Fire CTAS command. Eg:
CREATE TABLE new_table_name AS (SELECT * FROM hive.mytable);
Check /tmp/abc
directory, you will find JSON file.
Upvotes: 5