Hi Fernando,
Yes, the spark-tsfile connector supports writing tsfiles.
Firstly, you need to create and construct a DataFrame (there are many ways to
construct DataFrames like toDF(), createDataFrame(), or use json / csv files to
import as you wish).
Then, you could insert the DataFrame in tsfile like:
df.show // check whether your df is right
df.write.tsfile("hdfs://localhost:9000/output”)
However, there is a drawback because all data is inserted in one tsfile. And
also, the data in DataFrame needs to be in time order (I think this could be
operated by DataFrame function)
If you’d like to store data in different files, you have to separate data
manually.
So I actually recommend other inserting data ways : )
Best,
-----------------------------------
Zesong Sun
School of Software, Tsinghua University
孙泽嵩
清华大学 软件学院
> 2020年3月26日 02:28,Fernando Antunes <[email protected]> 写道:
>
> Zesong Sun, It works. Thanks.
>
> I have installed IOTDB 0.9.1, Grafana 6.7.1.1, IOTDB-Grafana, and Spark-IOTDB
> Connector.
>
> Successfully query IOTBD using Spark using the example into IOTDB web page.
>
>
> scala> import org.apache.iotdb.spark.db._
> import org.apache.iotdb.spark.db._
>
> scala> val df =
> spark.read.format("org.apache.iotdb.spark.db").option("url","jdbc:iotdb://xxxxx:6667/").option("sql","select
> * from root").load
> df: org.apache.spark.sql.DataFrame = [Time: bigint, root.ln.wf01.wt01.status:
> boolean ... 1 more field]
>
> scala> df.printSchema()
> root
> |-- Time: long (nullable = false)
> |-- root.ln.wf01.wt01.status: boolean (nullable = true)
> |-- root.ln.wf01.wt01.temperature: float (nullable = true)
>
>
> scala> df.show()
> +----+------------------------+-----------------------------+
>
> |Time|root.ln.wf01.wt01.status|root.ln.wf01.wt01.temperature|
> +----+------------------------+-----------------------------+
> | 100| true| null|
> | 200| false| 20.71|
> +----+------------------------+-----------------------------+
>
> A question.
>
> Can Spark insert data into IOTDB ?
>
> Could you provide same example ?
>
>
>
>> On 29 Feb 2020, at 06:29, Fernando Antunes <[email protected]> wrote:
>>
>> Very good. I will try and keep in touch.
>>
>> Thanks. Have a ince weekend.
>>
>>
>>> On 28 Feb 2020, at 22:11, 孙泽嵩 <[email protected]> wrote:
>>>
>>> Hi,
>>>
>>> Thanks for your concern very much!
>>>
>>> You could use spark-iotdb / spark-tsfile connector with 2.3.2 version.
>>> (Actually, only < 2.2 version is not supported).
>>>
>>> If you meet any questions, don’t hesitate to ask and I’d like to help you :
>>> )
>>>
>>>
>>> Best,
>>> -----------------------------------
>>> Zesong Sun
>>> School of Software, Tsinghua University
>>>
>>> 孙泽嵩
>>> 清华大学 软件学院
>>>
>>>> 2020年2月29日 03:50,Fernando Antunes <[email protected]> 写道:
>>>>
>>>> Hi. I’ve seen that Spark 2.4.3 is one of the System Requirements to use
>>>> this connector.
>>>>
>>>> I am a user of the HortonWorks/Cloudera software, and the Spark version is
>>>> 2.3.2 and Scala 2.11.12.
>>>>
>>>> Give some hope, please !
>>>>
>>>> Is it possible to use TSFile or IoTDB with 2.3.2 version? Even with some
>>>> limitations?
>>>>
>>>>
>>>
>>
>