0

我需要将查询导出到文件。我正在尝试

(SELECT A.*
FROM dfs.ff.`filea.json` A
  LEFT JOIN dfs.ff.`fileb.json` B ON (A.quote = B.quote)
WHERE B.C IS NULL) ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
STORED AS TEXTFILE LOCATION dfs.ff.`result.csv`;

但是给我一个错误

4

3 回答 3

0

Use BCP utility

bcp "SELECT A.*
FROM dfs.ff.`filea.json` A
  LEFT JOIN dfs.ff.`fileb.json` B ON (A.quote = B.quote)
WHERE B.C IS NULL" queryout "D:\MyTable.csv" -c -t , -S SERVERNAME -T

The -c argument specifies character output, as opposed to SQL's native binary format; this defaults to tab-separated values, but -t , changes the field terminator to commas. -T specifies Windows authentication ("trusted connection"), otherwise use -U MyUserName -P MyPassword.

This doesn't export column headers by default. You need to use a UNION ALL for headers

OR

Use SQLCMD



 SQLCMD -S SERVERNAME -E -Q "SELECT A.*
    FROM dfs.ff.`filea.json` A
      LEFT JOIN dfs.ff.`fileb.json` B ON (A.quote = B.quote)
    WHERE B.C IS NULL"
        -s "," -o "D:\MyData.csv" 

Also

http://www.egenconsulting.com/output-sql-to-csv/

http://solvedstack.com/questions/is-there-a-select-into-outfile-equivalent-in-sql-server-management-studio

于 2015-07-17T18:14:22.433 回答
0

使用 Drill shell 命令 !record 将所有输出记录到指定文件中。http://drill.apache.org/docs/configuring-the-drill-shell/

于 2015-07-23T18:08:03.370 回答
0

为此目的使用 CTAS。不要忘记定义store.format(默认为镶木地板)。文档参考:https ://drill.apache.org/docs/create-table-as-ctas/ 。

于 2019-10-25T10:05:12.443 回答