Sqoop - 日期 - 时间戳 [英] Sqoop - Date -timestamp
问题描述
我试图将Oracle中的数据转换为Hadoop。
在Oracle方面,日期字段是格式为'10 / 01/2015 12:00:00 AM'的时间戳。我如何在月,日和年过滤器?
I am trying to sqoop in the data from Oracle into Hadoop. In the Oracle side the date field is timestamp with format: '10/01/2015 12:00:00 AM'. How do I just put filter on month, day, and year?
过滤器中不需要小时和分钟,但是加载到HDFS中的数据需要具有10/01/2015 12:00:00 AM格式。任何想法?我看着其他的计算器,没有找到它的格式。谢谢!!
Don't need hours and min in the filter, however the data that gets loaded into HDFS needs to have 10/01/2015 12:00:00 AM' format. Any idea? I looked at other stackoverflow, didn't find it this format. Thanks!!
请参阅下面的代码。我没有得到任何结果。
Please see the code below. I don't get any results.
sqoop import \
--compress \
--target-dir /tmp/inbound/employee \
--query "SELECT EMPLOYEE_ID,NAME,ZIP_CODE,START_DATE FROM TEST_DB_A.EMPLOYEE WHERE EMPLOYEE_ID = '12345' and ACTIVE_EMP = 'YES' and CAST(START_DATE as DATE) = '2015-10-01' and \$CONDITIONS" \
--connect jdbc:oracle:thin:@xyz.xyz.com:11234/TEST \
--username 'xyz' \
--password 'xyz' \
--hive-drop-import-delims -m 1 \
--fields-terminated-by , \
--escaped-by \\ \
--split-by EMPLOYEE_ID
推荐答案
我们可以在Oracle端使用 to_char()
函数:
we can use to_char()
function on the Oracle side:
使用:
to_char(START_DATE, 'mm/dd/yyyy hh:mi:ss am')
而不是:
instead of:
START_DATE
这篇关于Sqoop - 日期 - 时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!