This is an automated email from the ASF dual-hosted git repository. xuekaifeng pushed a commit to branch xkf_test in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit da76af1b403ee795f8a07667d9030b24b9b4dfba Author: 151250176 <[email protected]> AuthorDate: Mon Oct 11 19:27:37 2021 +0800 update doc --- docs/UserGuide/Ecosystem Integration/Spark IoTDB.md | 15 ++++++++++++++- spark-iotdb-connector/Readme.md | 19 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/docs/UserGuide/Ecosystem Integration/Spark IoTDB.md b/docs/UserGuide/Ecosystem Integration/Spark IoTDB.md index 2b8507d..6aa16d2 100644 --- a/docs/UserGuide/Ecosystem Integration/Spark IoTDB.md +++ b/docs/UserGuide/Ecosystem Integration/Spark IoTDB.md @@ -114,9 +114,22 @@ You can also use narrow table form which as follows: (You can see part 4 about h | 5 | root.ln.wf02.wt01 | false | null | null | | 6 | root.ln.wf02.wt02 | null | ccc | null | +#### Get narrow form of data +``` +spark-shell --jars spark-iotdb-connector-0.13.0-SNAPSHOT.jar,iotdb-jdbc-0.13.0-SNAPSHOT-jar-with-dependencies.jar + +import org.apache.iotdb.spark.db._ + +val df = spark.read.format("org.apache.iotdb.spark.db").option("url","jdbc:iotdb://127.0.0.1:6667/").option("sql","select * from root align by device").load + +df.printSchema() + +df.show() +``` + #### Transform between wide and narrow table -* from wide to narrow +* from wide to narrow (you may use align by device from "Get narrow from of data" to get narrow form directly) ``` import org.apache.iotdb.spark.db._ diff --git a/spark-iotdb-connector/Readme.md b/spark-iotdb-connector/Readme.md index 277f97e..6ba35e5 100644 --- a/spark-iotdb-connector/Readme.md +++ b/spark-iotdb-connector/Readme.md @@ -120,9 +120,22 @@ You can also use narrow table form which as follows: (You can see part 4 about h | 5 | root.ln.wf02.wt01 | false | null | null | | 6 | root.ln.wf02.wt02 | null | ccc | null | -# 4. Transform between wide and narrow table +# 4. Get narrow form of data +``` +spark-shell --jars spark-iotdb-connector-0.13.0-SNAPSHOT.jar,iotdb-jdbc-0.13.0-SNAPSHOT-jar-with-dependencies.jar + +import org.apache.iotdb.spark.db._ + +val df = spark.read.format("org.apache.iotdb.spark.db").option("url","jdbc:iotdb://127.0.0.1:6667/").option("sql","select * from root align by device").load + +df.printSchema() + +df.show() +``` + +# 5. Transform between wide and narrow table -## from wide to narrow +## from wide to narrow (you may use align by device from 4 to get narrow form directly) ``` import org.apache.iotdb.spark.db._ @@ -137,7 +150,7 @@ import org.apache.iotdb.spark.db._ val wide_df = Transformer.toWideForm(spark, narrow_df) ``` -# 5. Java user guide +# 6. Java user guide ``` import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Row;
