【问题标题】:Need to pass widget value to the Databricks SQL table location path需要将小部件值传递给 Databricks SQL 表位置路径
【发布时间】:2023-01-03 18:17:53
【问题描述】:

我正在尝试将小部件值传递给 Databricks SQL 表位置路径,但出现解析异常错误。有人可以分享怎么做吗?

代码:

%sql 
  create table if not exists CTRL.t_migration_Status (
      Run_Seq_num int,
      Table_Id varchar(10),
      Table_owner varchar(50),
      Table_Name varchar(50),
      hash_columns varchar(100),
      Load_type varchar(50),
      copy_date varchar(100),
      Source_rec_count int,
      target_Rec_count int,
      Rec_vld_status varchar(10),
      Source_hash_total int,
      Target_hash_total int,
      Hash_total_vld_Status varchar(10)
    )location "abfss://"${storage_account_containervar}"@xxx.dfs.core.windows.net/CTRL/";

错误:

ParseException: 
extraneous input '"@sourcesgdevops.dfs.core.windows.net/CTRL/"' expecting {<EOF>, ';'}(line 15, pos 24)

== SQL ==
create table if not exists CTRL.t_migration_Status (
      Run_Seq_num int,
      Table_Id varchar(10),
      Table_owner varchar(50),
      Table_Name varchar(50),
      hash_columns varchar(100),
      Load_type varchar(50),
      copy_date varchar(100),
      Source_rec_count int,
      target_Rec_count int,
      Rec_vld_status varchar(10),
      Source_hash_total int,
      Target_hash_total int,
      Hash_total_vld_Status varchar(10)
    )location "abfss://""@sourcesgdevops.dfs.core.windows.net/CTRL/"

enter image description here

我试图传递值,但因解析异常而失败。

【问题讨论】:

    标签: databricks azure-databricks databricks-sql


    【解决方案1】:

    我试图在我的环境中重现相同的内容并得到以下结果

    请按照以下步骤操作:

    首先创建一个小部件。在小部件中输入您的容器名称:

    dbutils.widgets.text("foo", "text","enter_st")
    

    使用 Access_key 配置您的存储帐户。

    spark.conf.set("fs.azure.account.key.<storage_account_name>.dfs.core.windows.net","Access_key")
    

    现在,使用下面的代码,我得到了这些没有错误的结果。

    %sql
    create table if not exists CTRL.t_migration_Status12 (
          Run_Seq_num int,
          Table_Id varchar(10),
          Table_owner varchar(50),
          Table_Name varchar(50),
          hash_columns varchar(100),
          Load_type varchar(50),
          copy_date varchar(100),
          Source_rec_count int,
          target_Rec_count int,
          Rec_vld_status varchar(10),
          Source_hash_total int,
          Target_hash_total int,
          Hash_total_vld_Status varchar(10)
        )location "abfss://${foo}@<Storage_account_name>.dfs.core.windows.net/dem";
    

    【讨论】:

      猜你喜欢
      • 2020-04-02
      • 2019-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-06
      • 2017-08-08
      相关资源
      最近更新 更多