Databricks Spark-Redshift:Sortkeys无效

时间:2017-05-26 13:38:19

标签: scala apache-spark amazon-redshift databricks

我正在尝试按照以下说明从scala代码添加排序键:https://github.com/databricks/spark-redshift

df.write
  .format(formatRS)
  .option("url", connString)
  .option("jdbcdriver", jdbcDriverRS)
  .option("dbtable", table)
  .option("tempdir", tempDirRS + table)
  .option("usestagingtable", "true")
  .option("diststyle", "KEY")
  .option("distkey", "id")
  .option("sortkeyspec", "INTERLEAVED SORTKEY (id,timestamp)")
  .mode(mode)
  .save()

排序键实现错误,因为当我检查表信息时:

  

sort key = INTERLEAVED

我需要正确的方法来添加排序键。

1 个答案:

答案 0 :(得分:0)

实现没有错,错误的是它从“检查查询”返回

  

sort key = interleaved

令人困惑,相信发生了一些错误。

因此,如果您需要检查交错排序键,则应运行此查询:

select tbl as tbl_id, stv_tbl_perm.name as table_name, 
col, interleaved_skew, last_reindex
from svv_interleaved_columns, stv_tbl_perm
where svv_interleaved_columns.tbl = stv_tbl_perm.id
and interleaved_skew is not null;