Hive function quarter() returns 'invalid funct

2019-08-22 06:47发布

问题:

This says the function quarter() was introduced in Hive 1.3

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions

I am using the default version of HDInsight (3.1) to run Hadoop:

https://azure.microsoft.com/en-us/documentation/articles/hdinsight-component-versioning/

When I try to use the quarter function I get:

Logging initialized using configuration in file:/C:/apps/dist/hive-0.13.0.2.1.15.1-0001/conf/hive-log4j.properties SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/C:/apps/dist/hadoop-2.4.0.2.1.15.1-0001/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/C:/apps/dist/hbase-0.98.0.2.1.15.1-0001-hadoop2/lib/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] FAILED: SemanticException [Error 10011]: Line 10:1 Invalid function 'quarter'

What am I missing?

回答1:

Unfortunately HDInsight 3.1 is only running Hive 0.13.1 and the quarter function isn't available until version 1.3. You can see all of the hive release here



回答2:

If you're on an older version of hive that doesn't support quarter(), try this:

ceil(month(date) / 3.0)


回答3:

The Hive versions in various releases of HDInsight are given below. As per this, your hive version is 0.13.1 and the quarter is supported in hive version 1.3.

HDINSIGHT VERSION 3.2- Hive-0.14.0

HDINSIGHT VERSION 3.1- Hive-0.13.1

HDINSIGHT VERSION 3.0- Hive-0.12.0

HDINSIGHT VERSION 2.1- Hive-0.11.0