【问题标题】:Why Synapse is not working with my query?为什么 Synapse 无法处理我的查询?
【发布时间】:2021-10-13 07:28:22
【问题描述】:

我正在尝试在 Azure 的 Synapse Analytics 中使用查询,当我使用它时出现下一个错误:

在源“AgenciesInventoryQueryFromSynapsestg”:shaded.msdataflow.com.microsoft.sqlserver.jdbc.SQLServerException:第 1 行第 47 列解析错误:“WITH”附近的语法不正确。

这对我来说很奇怪,因为我之前在 Microsoft SQL Server Management 中测试了查询以将其添加到 Synapse,并且它在那里完美运行,查询是下一个:

WITH cte AS (Select abi_stg.mex_log_reverlog_agencies_inventory.centro, abi_stg.mex_log_reverlog_destinations_catalog.agencia,
abi_stg.mex_log_reverlog_agencies_inventory.material, abi_stg.mex_log_reverlog_agencies_inventory.almacen,
abi_stg.mex_log_reverlog_agencies_inventory.texto_breve_material, abi_stg.mex_log_reverlog_agencies_inventory.unidad_medida_base,
abi_stg.mex_log_reverlog_agencies_inventory.libre_utilizacion, abi_stg.mex_log_reverlog_agencies_inventory.control_calidad,
abi_stg.mex_log_reverlog_agencies_inventory.stock_no_disponible, abi_stg.mex_log_reverlog_agencies_inventory.bloqueado, abi_stg.mex_log_reverlog_agencies_inventory.devoluciones,
abi_stg.mex_log_reverlog_agencies_inventory.stock_en_transito, abi_stg.mex_log_reverlog_agencies_inventory.trasladando,
abi_stg.mex_log_reverlog_agencies_inventory.stock_bloqueado_em_valorado,
abi_stg.mex_log_reverlog_destinations_catalog.drv as zona,
abi_stg.mex_log_reverlog_destinations_catalog.subagencia, abi_stg.mex_log_reverlog_destinations_catalog.origen_jda, 
abi_stg.mex_log_reverlog_materials_catalog.id,
abi_stg.mex_log_reverlog_materials_catalog.marca,
abi_stg.mex_log_reverlog_materials_catalog.cupo, abi_stg.mex_log_reverlog_materials_catalog.tipo_envase, abi_stg.mex_log_reverlog_agencies_average_sales_catalog.ventas_promedio,
RANK() OVER (partition by abi_stg.mex_log_reverlog_agencies_inventory.centro order by abi_stg.mex_log_reverlog_agencies_average_sales_catalog.uen desc) as order_c
From abi_stg.mex_log_reverlog_agencies_inventory 
Left Join abi_stg.mex_log_reverlog_destinations_catalog
On abi_stg.mex_log_reverlog_agencies_inventory.centro = abi_stg.mex_log_reverlog_destinations_catalog.centro
Left Join abi_stg.mex_log_reverlog_materials_catalog
On abi_stg.mex_log_reverlog_agencies_inventory.material = abi_stg.mex_log_reverlog_materials_catalog.material
Left Join abi_stg.mex_log_reverlog_agencies_average_sales_catalog
On abi_stg.mex_log_reverlog_destinations_catalog.origen_jda = abi_stg.mex_log_reverlog_agencies_average_sales_catalog.zona)
select centro,agencia,material,almacen,texto_breve_material,unidad_medida_base,libre_utilizacion,control_calidad,stock_no_disponible,bloqueado,
devoluciones,stock_en_transito,trasladando,stock_bloqueado_em_valorado,zona,subagencia,origen_jda,id,marca,cupo,tipo_envase,ventas_promedio
from cte where order_c =1

知道这里出了什么问题吗?或任何解决方法的想法?

【问题讨论】:

    标签: sql azure azure-synapse


    【解决方案1】:

    目前不支持此功能,因此使用 Order By 子句。作为一种解决方法,您可以使用用户定义的表函数,例如 select * from udfGetData(),其中 SQL 中的 UDF 将返回一个表。此查询将生成您可以在数据流中使用的源表。

    示例:以下在 SSMS 中运行良好

    但在 ADF 中作为 Synapse 源:

    解决方法....

    根据需要创建用户定义的函数,例如:

    使用 Select 从函数中获取数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-10
      • 2022-12-23
      • 1970-01-01
      • 2013-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多