简体   繁体   English

如何创建日期格式为“ dd-MMM-yyyy”的配置单元表?

[英]How to create hive table with date format 'dd-MMM-yyyy'?

I,m trying to create a hive table for importing csv data into table where the date format in the csv file is 'dd-MMM-yyyy' (for example 20-Mar-2018). 我正在尝试创建一个配置单元表,用于将csv数据导入到表中,其中csv文件中的日期格式为'dd-MMM-yyyy'(例如20-Mar-2018)。 When i created table in hive it turns out the entire column of date into null values. 当我在蜂巢中创建表格时,它会将整个日期列转换为空值。 Can anyone suggest me how to figure out this? 谁能建议我如何解决这个问题?

My Query: 我的查询:

create external table new_stock (Symbol String,Series String,Dat date,Prev_Close float,Open_Price float,High_Price float,Low_Price float,Last_Price float,Close_Price float,Avg_Price float,Volume int,Turn_Over float,Trades int,Del_Qty int,DQPQ_Per float) row format delimited fields terminated by ',' stored as textfile LOCATION '/stock_details/' 

Finally some help from @leftjoin, i solved the problem of converting string date with format (dd-MMM-yyyy) to (dd-MM-yyyy) by using select query. 最后来自@leftjoin的一些帮助,我解决了使用选择查询将字符串日期格式为(dd-MMM-yyyy)转换为(dd-MM-yyyy)的问题。 It would work fine. 会很好的。

select from_unixtime(unix_timestamp(columnname ,'dd-MMM-yyyy'), 'dd-MM-yyyy') from tablename;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pyspark DD-MMM-YYYY(字符串格式)到时间戳 - Pyspark DD-MMM-YYYY (string format) to timestamp 从Java中的字符串中提取多个日期(dd-MMM-yyyy格式) - Extract multiple dates (dd-MMM-yyyy format) from a string in java 从字符串中提取日期格式为“DD MMM YYYY” - Extract date from string in format “DD MMM YYYY” 如何检查日期是否格式正确,即yyyy-mmm-dd? - How to check if date is in correct format i.e. yyyy-mmm-dd? 处理 Python 日期格式 EEE MMM dd HH:mm:ss zzz yyyy - Handle in Python date in format EEE MMM dd HH:mm:ss zzz yyyy 日期的正则表达式,格式为DD / MMM / YYYY:HH24:mm:ss - Regex for date in format DD/MMM/YYYY:HH24:mm:ss c# 如何从包含格式的字符串中仅提取格式(例如 string = "Printed on {0:dd MMM yyyy}" 并且我想要 dd MMM yyyy - c# How to extract just the format from a string containing a format (e.g. string = "Printed on {0:dd MMM yyyy}" and I want dd MMM yyyy 在C ++中将日期格式Www Mmm dd hh:mm:ss yyyy转换为dd hh:mm:ss字符串 - convert date format Www Mmm dd hh:mm:ss yyyy to dd hh:mm:ss string in c++ 将mysql中的日期字符串从dd / mm / yyyy hh:mm:ss转换为DD MMM YYYY - convert date string sored in mysql from dd/mm/yyyy hh:mm:ss to DD MMM YYYY 如何在JavaScript中以dd-Mon-yyyy格式检查日期? - How to check date in dd-Mon-yyyy format in javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM