为什么我通过Hutonworks ODBC驱动程序通过Openquery在SSMS中运行的Hive QL查询产生错误?

问题描述 投票:0回答:1

我使用Apache Hive的Hortonworks ODBC驱动程序建立了与Hive服务器的连接。版本信息如下:

ODBC connector version info

OS: Windows Server 2012 R2 Standard
Hive: 1.2.1000.2.6.5.4-1
Hadoop: 2.7.3.2.6.5.4-1
Hortonworks ODBC Driver for Apache Hive
ODBC Version: 03.80
Driver Version: 2.1.12.1017
Bitness: 64-bit
Locale: en_US

我可以使用我在Teradata SQL Assistant中配置的连接器运行下面的查询,没有任何问题。我将DSN设置为SSMS中的链接服务器。但是,当我尝试使用openquery在SSMS中运行查询时,我遇到了一些问题。我的SQL Server上的信息如下:

Microsoft SQL Server 2016 (SP2-CU3) (KB4458871) - 13.0.5216.0 (X64) Sep 13 2018 22:16:01 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: ) (Hypervisor)

以下是我要查询的表格中的一些信息:

表名:instrumentapps_event

table info

使用OPENQUERY,我能够通过SSMS使用以下查询查询Hive DB:

SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')

上面的查询返回所需表的内容。但是,下面的查询会产生错误:

SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >= to_date(''2019-03-01'')')

错误如下:

Msg 7355, Level 16, State 1, Line 1

The OLE DB provider "MSDASQL" for linked server "KMhivehttp" supplied inconsistent metadata for a column. The name was changed at execution time.

我怎样才能解决这个问题?

tsql hive ssms hiveql hortonworks-data-platform
1个回答
0
投票

虽然我不确定如何解决我之前遇到的问题(我怀疑它是Hortonworks ODBC驱动程序的一个错误),但我确实发现了一种解决方法。

而不是运行:

SELECT * FROM OPENQUERY(KMhivehttp, 
    'SELECT * 
     FROM dmfwk_gold.instrumentapps_event 
     WHERE to_date(from_unixtime(UNIX_TIMESTAMP(load_ts,''yyyy/MM/dd''))) >= 
     to_date(''2019-03-01'')
    ')

我现在用:

SELECT * FROM OPENQUERY(KMhivehttp, 'select * from dmfwk_gold.instrumentapps_event')
WHERE load_ts >= CAST('2019-03-01' AS DATE);

这允许我避免任何元数据错误。

© www.soinside.com 2019 - 2024. All rights reserved.