简体   繁体   English

SQL:检查其值为“ Date”但类型为“ String”的列的格式

[英]SQL : Checking format of column whose value is 'Date' but type is 'String'

I am running a ETL job which is failing due to data quality issues. 我正在运行ETL作业,由于数据质量问题,该作业失败了。 In my source, my date column is in String format and I am converting it to a TIMESTAMP using to_timestamp() method while storing it into target. 在我的源代码中,我的日期to_timestamp() String格式,并且在将它存储到目标时使用to_timestamp()方法将其转换为TIMESTAMP

This job is failing when one date value(in String format) comes as 2016-06- instead of 2016-11-10 06:07:48.633 . 当一个日期值(字符串格式)为2016-06-而不是2016-11-10 06:07:48.633时,此作业失败。 Due to the incorrect value, I can't convert it to a timestamp and my whole job fails. 由于值不正确,我无法将其转换为时间戳,并且我的整个工作都失败了。

How do I apply a format check in a generic way to verify that date(in String data type) is in correct format before converting it to timestamp? 在将日期转换为时间戳之前,如何以通用方式应用格式检查以验证日期(字符串数据类型)的格式正确?

You could use Isdate() function to check if a string is date or not. 您可以使用Isdate()函数检查字符串是否为日期。

Use this function at filter level and filter the invalid dates and load the rest. 在过滤器级别使用此功能,过滤无效日期并加载其余日期。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM