【问题标题】:Python Azure Databricks create delta table exception: no transaction log presentPython Azure Databricks 创建增量表异常:不存在事务日志
【发布时间】:2022-06-10 19:56:58
【问题描述】:

我正在使用 Azure Databricks,并且正在尝试创建一个 Delta 表。

Python 代码:

delta_save_path = "/mnt/ops/test/alerts"
try: 
  sqlContext.sql("CREATE TABLE ops.test_alerts USING DELTA LOCATION '" + delta_save_path + "'")
except Exception as e:
  print(str(e))

错误信息:

You are trying to create an external table `ops`.`test_alerts`
from `/mnt/ops/test/alerts` using Databricks Delta, but there is no transaction log present at
`/mnt/ops/test/alerts/_delta_log`. Check the upstream job to make sure that it is writing using
format("delta") and that the path is the root of the table.

我做错了什么?

【问题讨论】:

    标签: python databricks azure-databricks delta-lake


    【解决方案1】:

    您使用的语法是当您想从现有数据创建表时。但看起来您正在创建一个空表,因此在这种情况下,您需要为您的表提供一个架构,如下所示(架构是虚构的):

    CREATE TABLE ops.test_alerts (
      id int,
      metric_nam string,
      timestamp timestamp
    ) USING DELTA 
    LOCATION '<some location>'
    

    详情请见CREATE TABLE documentation

    【讨论】:

      猜你喜欢
      • 2022-11-24
      • 2021-11-06
      • 2017-11-15
      • 2022-01-01
      • 2022-10-05
      • 2021-09-05
      • 2016-12-05
      • 2014-03-04
      • 1970-01-01
      相关资源
      最近更新 更多