You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2017/05/02 14:12:28 UTC

[04/50] [abbrv] incubator-carbondata git commit: Update faq.md

Update faq.md

Update faq.md

Update faq.md


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/9d70dff8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/9d70dff8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/9d70dff8

Branch: refs/heads/12-dev
Commit: 9d70dff81921395109fcb417b766c4cf5e3ecdbc
Parents: 0a11c2a
Author: chenerlu <ch...@huawei.com>
Authored: Thu Apr 20 21:16:42 2017 +0800
Committer: chenliang613 <ch...@huawei.com>
Committed: Sat Apr 22 10:52:01 2017 +0800

----------------------------------------------------------------------
 docs/faq.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/9d70dff8/docs/faq.md
----------------------------------------------------------------------
diff --git a/docs/faq.md b/docs/faq.md
index 57ac171..3b22260 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -26,6 +26,7 @@
 * [How to specify store location while creating carbon session?](#how-to-specify-store-location-while-creating-carbon-session)
 * [What is Carbon Lock Type?](#what-is-carbon-lock-type)
 * [How to resolve Abstract Method Error?](#how-to-resolve-abstract-method-error)
+* [How Carbon will behave when execute insert operation in abnormal scenarios?](#how-carbon-will-behave-when-execute-insert-operation-in-abnormal-scenarios)
 
 ## What are Bad Records?
 Records that fail to get loaded into the CarbonData due to data type incompatibility or are empty or have incompatible format are classified as Bad Records.
@@ -74,4 +75,58 @@ The property carbon.lock.type configuration specifies the type of lock to be acq
 ## How to resolve Abstract Method Error?
 In order to build CarbonData project it is necessary to specify the spark profile. The spark profile sets the Spark Version. You need to specify the ``spark version`` while using Maven to build project.
 
+## How Carbon will behave when execute insert operation in abnormal scenarios?
+Carbon support insert operation, you can refer to the syntax mentioned in [DML Operations on CarbonData](http://carbondata.apache.org/dml-operation-on-carbondata).
+First, create a soucre table in spark-sql and load data into this created table. 
+```
+CREATE TABLE source_table(
+id String,
+name String,
+city String)
+ROW FORMAT DELIMITED FIELDS TERMINATED BY ",";
+```
+```
+SELECT * FROM source_table;
+id  name    city
+1   jack    beijing
+2   erlu    hangzhou
+3   davi    shenzhen
+```
+**Scenario 1** :
+
+Suppose, the column order in carbon table is different from source table, use script "SELECT * FROM carbon table" to query, will get the column order similar as source table, rather than in carbon table's column order as expected. 
+```
+CREATE TABLE IF NOT EXISTS carbon_table(
+id String,
+city String,
+name String)
+STORED BY 'carbondata';
+```
+```
+INSERT INTO TABLE carbon_table SELECT * FROM source_table;
+```
+```
+SELECT * FROM carbon_table;
+id  city    name
+1   jack    beijing
+2   erlu    hangzhou
+3   davi    shenzhen
+```
+As result shows, the second column is city in carbon table, but what inside is name, such as jack. This phenomenon is same with insert data into hive table.
+
+If you want to insert data into corresponding column in carbon table, you have to specify the column order same in insert statment. 
+```
+INSERT INTO TABLE carbon_table SELECT id, city, name FROM source_table;
+```
+
+**Scenario 2** :
+
+Insert operation will be failed when the number of column in carbon table is different from the column specified in select statement. The following insert operation will be failed.
+```
+INSERT INTO TABLE carbon_table SELECT id, city FROM source_table;
+```
+**Scenario 3** :
+
+When the column type in carbon table is different from from the column specified in select statement. The insert operation will still success, but you may get NULL in result, because NULL will be substitute value when conversion type failed.
+