Member since
10-04-2016
243
Posts
281
Kudos Received
43
Solutions
My Accepted Solutions
Title | Views | Posted |
---|---|---|
1172 | 01-16-2018 03:38 PM | |
6139 | 11-13-2017 05:45 PM | |
3033 | 11-13-2017 12:30 AM | |
1518 | 10-27-2017 03:58 AM | |
28428 | 10-19-2017 03:17 AM |
04-01-2017
03:44 AM
@Deepesh - I checked the Hive-11217 JIRA you posted here. It appears the fix was applied to Hive versions 1.3.0 and 2.0. Does that mean that people using Hive Versions lowers than 1.3.0 will face this issue even if they are using CAST ?
... View more
04-01-2017
03:32 AM
@Deepesh - Yes, I am using CAST to specify the type. In my case the select has - "CAST(NULL AS bigint)".
... View more
04-01-2017
01:13 AM
1 Kudo
I am using HDP-2.4.0.7 and ORC is the default format for Hive. One of my CTAS Hive query to create a table, fails with the following error: return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.IllegalArgumentException: Unknown primitive type VOID
... View more
Labels:
- Labels:
-
Apache Hive
03-21-2017
07:06 PM
It is weird but a restart indeed solved the issue. Wondering what the root cause could be. If you have any luck arriving at the root cause, please share here in future. 🙂
... View more
03-21-2017
01:56 AM
3 Kudos
@Nandini Bhattacharjee You must use a custom UDF for your usecase. I had some time to modify one of my UDF to suit your usecase. To use this udf, you must pass 3 arguments: 1. Base Date 2. Count [this represents the number of dates you want to generate. If the count you input is positive then the dates generated will be starting from date that you passed above. If the count is negative, then the dates generated will be before the date you passed above. This will be demonstrated in the demo below. 3. Date format as per Joda specs https://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html Here is the usage demo, highlighted in yellow: Here is the source code for the UDF: package com.dc.hadoop;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
import org.apache.hadoop.io.Text;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
/**
* UDF to generate all dates given [baseDate, count, dateformat]
*/
public final class DateGen extends GenericUDF
{
Converter[] converters = null;
StringObjectInspector inputOI = null;
List<Object> dates = new ArrayList<>();
@Override
public ObjectInspector initialize(ObjectInspector[] objectInspectors) throws UDFArgumentException {
if(objectInspectors.length != 3) {
throw new UDFArgumentException("All params are required: baseDate, count and dateFormat");
}
if (!(objectInspectors[0] instanceof StringObjectInspector)
|| !(objectInspectors[1] instanceof StringObjectInspector)
|| !(objectInspectors[2] instanceof StringObjectInspector)) {
throw new UDFArgumentException("All input should be of type STRING");
}
this.inputOI = (StringObjectInspector) objectInspectors[0];
this.converters = new Converter[objectInspectors.length];
converters[0] = ObjectInspectorConverters.getConverter(inputOI, PrimitiveObjectInspectorFactory.writableStringObjectInspector);
return ObjectInspectorFactory.getStandardListObjectInspector(PrimitiveObjectInspectorFactory.writableStringObjectInspector);
}
@Override
public Object evaluate(DeferredObject[] deferredObjects) throws HiveException {
String start = inputOI.getPrimitiveJavaObject(deferredObjects[0].get());
String counter = inputOI.getPrimitiveJavaObject(deferredObjects[1].get());
String dateFormat = inputOI.getPrimitiveJavaObject(deferredObjects[2].get());
if (start == null || counter == null || dateFormat == null) {
return null;
}
DateTimeFormatter formatter = DateTimeFormat.forPattern(dateFormat);
DateTime baseDate = null;
Integer count = null;
DateTime endDate = null;
try {
baseDate = formatter.parseDateTime(start);
count = Integer.valueOf(counter);
} catch (IllegalArgumentException e) {
System.err.println("ERROR: DateRangeToDateArray - can't parse baseDate or count: " + baseDate + " " + count);
baseDate = null;
}
if ( baseDate == null || count == null ) {
return null;
}
if(count<0){
endDate = baseDate;
baseDate = baseDate.minusDays(-1*count);
}else{
endDate = baseDate.plusDays(count);
}
return getDatesArrayForRange(baseDate, endDate, formatter);
}
private List<Object> getDatesArrayForRange(DateTime start,
DateTime end, DateTimeFormatter formatter) {
dates.clear();
while (start.isBefore(end) || start.isEqual(end)) {
Text dateAsText = new Text(start.toString(formatter));
dates.add(dateAsText);
start = start.plusDays(1);
}
return dates;
}
@Override
public String getDisplayString(String[] strings) {
return "Generate all dates given [baseDate, count, dateformat]";
}
}
Also, attached zip file containing sample jar file that I used for demo dtgen.zip Hope this helps.
... View more
03-17-2017
04:00 PM
@Nandini Bhattacharjee do you mean you want to generate dates given a range. say x days from the past till today, or x days in future from today ?
... View more
03-16-2017
03:48 PM
@Nandini Bhattacharjee In lower versions of Hive, the following worked for me: select TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP())); In higher versions, you can use : select CURRENT_DATE;
... View more
03-16-2017
03:13 PM
@Ramesh Raja - Pls consider accepting the answer if this has helped you at all. Thank you.
... View more
03-16-2017
03:53 AM
@Artem Ervits - different workflows failed on different nodes, however, their re-attempt were on the same node as their first attempt. also the yarn logs do not exist for the failed/killed ones, i mean, i tried > yarn logs -applicationId <failedAppId> but it said the logs do not exist. In order to verify the command i tried to get logs for a successful one and was able to get logs. Thank you.
... View more