数据湖探索 DLI-OBS输入流:示例

时间:2024-11-16 13:21:40

示例

  • 从OBS的桶读取对象为input.csv的文件,文件以'\n'划行, 以','划列。

    测试输入数据input.csv可以先通过新建input.txt复制如下文本数据,再另存为input.csv格式文件。将input.csv上传到对应OBS桶目录下。例如,当前上传到:“dli-test-obs01”桶目录下。

    1,2,3,4,1403149534
    5,6,7,8,1403149535
    创建表参考如下:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    CREATE SOURCE STREAM car_infos (
      car_id STRING,
      car_owner STRING,
      car_brand STRING,
      car_price INT,
      car_timestamp LONG
    )
      WITH (
        type = "obs",
        bucket = "dli-test-obs01",
        region = "xxx",
        object_name = "input.csv",
        row_delimiter = "\n",
        field_delimiter = ","
    );
    
  • 从OBS的桶读取对象为input.json的文件,文件以'\n'划行。
    CREATE SOURCE STREAM obs_source (
      str STRING
    )
      WITH (
        type = "obs",
        bucket = "obssource",
        region = "xxx",
        encode = "json",
        row_delimiter = "\n",
        object_name = "input.json"
    );
support.huaweicloud.com/sqlref-flink-dli/dli_08_0236.html