如何以hadoop.hive.serde2.OpenCSVSerde格式查询Athena字符串到目前为止

时间:2017-09-08 12:42:11

标签: amazon-web-services amazon-s3 amazon-athena

您好我已在AWS Athena中创建以下架构以从AWS S3读取csv文件

CREATE EXTERNAL TABLE IF NOT EXISTS axlargetable.mine (
  createdate string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
   'separatorChar' = ',',
   'quoteChar' = '\"',
   'escapeChar' = '\\'
   ) 
LOCATION 's3://ax-large-table/test/'
TBLPROPERTIES ('has_encrypted_data'='false')

“createdate”列包含以下值

7/01/2017 5:40:05 PM
7/03/2017 5:40:05 PM
7/04/2017 5:40:05 PM
7/05/2017 5:40:05 PM
7/06/2017 5:40:05 PM
7/31/2017 5:40:05 PM
7/31/2017 5:40:05 PM
7/31/2017 5:40:05 PM
7/31/2017 5:40:05 PM

如何查询“createdate”列值作为日期格式?样本查询,如

Select * from axlargetable.mine 
where createdate between '7/03/2017' and '7/31/2017'

由于

1 个答案:

答案 0 :(得分:5)

我担心OpenCSVSerDe不支持使用某些非ISO格式解析Private Sub Cancel_New_Record_Click() '-------------------------------------------------- 'deletes the newly created record from the database '-------------------------------------------------- If MsgBox("Are you sure you want to delete this record?", vbYesNo) = vbYes Then 'grab the id of the current check record for later Dim checkID As Integer checkID = Me.Check_ID 'delete the current check record DoCmd.RunCommand acCmdDeleteRecord 'now delete any orphan entities from the entity table CurrentDb.Execute "DELETE * FROM entities WHERE entities.[Check ID] = " & checkID & ";" 'close the form and return to the menu DoCmd.Close acForm, "checks" DoCmd.OpenForm "menu" End If End Sub 类型。您可以绕过此行为的唯一方法是将字符串转换为查询中的日期。

在这种情况下,您需要使用date功能。

parse_date