Hive function quarter() returns 'invalid function'
Asked Answered
K

3

0

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?

Kolkhoz answered 28/7, 2015 at 22:57 Comment(1)
the work around for me was to use a case statement to get the quarter: case month(gmtdatetime) When 1 then 1 When 2 then 1 When 3 then 1 When 4 then 2 When 5 then 2 When 6 then 2 When 7 then 3 When 8 then 3 When 9 then 3 Else 4 end as QuarterOfKolkhoz
G
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

Genovera answered 29/7, 2015 at 0:35 Comment(3)
Is there a work around so I can group and sum using quarter() ?Kolkhoz
You could just add the version 1.3 Hive jar to the cluster during creation and then reference the quarter UDF as a temporary function. blogs.msdn.com/b/bigdatasupport/archive/2014/01/14/…Genovera
The same is valid for the FIRST() functionCheslie
W
2

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

ceil(month(date) / 3.0)
Wakerobin answered 18/2, 2016 at 6:4 Comment(0)
G
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

Genovera answered 29/7, 2015 at 0:35 Comment(3)
Is there a work around so I can group and sum using quarter() ?Kolkhoz
You could just add the version 1.3 Hive jar to the cluster during creation and then reference the quarter UDF as a temporary function. blogs.msdn.com/b/bigdatasupport/archive/2014/01/14/…Genovera
The same is valid for the FIRST() functionCheslie
O
0

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

Ogle answered 29/7, 2015 at 5:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.