Skip to content

Commit

Permalink
Merge pull request #1626 from taozhi8833998/fix-extract-field-bigquery
Browse files Browse the repository at this point in the history
fix: extract filed bug in bigquery
  • Loading branch information
taozhi8833998 authored Oct 17, 2023
2 parents 6d93a5d + 69946a6 commit efa41b4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pegjs/bigquery.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,10 @@ any_value_func
}

extract_filed
= f:('CENTURY'i / 'DAY'i / 'DATE'i / 'DECADE'i / 'DOW'i / 'DOY'i / 'EPOCH'i / 'HOUR'i / 'ISODOW'i / 'ISOWEEK'i / 'ISOYEAR'i / 'MICROSECONDS'i / 'MILLENNIUM'i / 'MILLISECONDS'i / 'MINUTE'i / 'MONTH'i / 'QUARTER'i / 'SECOND'i / 'TIME'i / 'TIMEZONE'i / 'TIMEZONE_HOUR'i / 'TIMEZONE_MINUTE'i / 'WEEK'i / 'YEAR'i) {
= f:(
'YEAR_MONTH'i / 'DAY_HOUR'i / 'DAY_MINUTE'i / 'DAY_SECOND'i / 'DAY_MICROSECOND'i / 'HOUR_MINUTE'i / 'HOUR_SECOND'i/ 'HOUR_MICROSECOND'i / 'MINUTE_SECOND'i / 'MINUTE_MICROSECOND'i / 'SECOND_MICROSECOND'i / 'TIMEZONE_HOUR'i / 'TIMEZONE_MINUTE'i
/ 'CENTURY'i / 'DAYOFWEEK'i / 'DAY'i / 'DATE'i / 'DECADE'i / 'DOW'i / 'DOY'i / 'EPOCH'i / 'HOUR'i / 'ISODOW'i / 'ISOWEEK'i / 'ISOYEAR'i / 'MICROSECONDS'i / 'MILLENNIUM'i / 'MILLISECONDS'i / 'MINUTE'i / 'MONTH'i / 'QUARTER'i / 'SECOND'i / 'TIME'i / 'TIMEZONE'i / 'WEEK'i / 'YEAR'i
) {
return f
}
extract_func
Expand Down
7 changes: 7 additions & 0 deletions test/bigquery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,13 @@ describe('BigQuery', () => {
'SELECT DATE_TRUNC(CURRENT_DATE(), INTERVAL 1 ISOYEAR)'
]
},
{
title: 'extract field',
sql: [
'SELECT TIMESTAMP(DATE_SUB(CURRENT_DATETIME(), INTERVAL EXTRACT(DAYOFWEEK FROM CURRENT_DATETIME())-1 DAY))',
'SELECT TIMESTAMP(DATE_SUB(CURRENT_DATETIME(), INTERVAL EXTRACT(DAYOFWEEK FROM CURRENT_DATETIME()) - 1 DAY))'
]
},
]

SQL_LIST.forEach(sqlInfo => {
Expand Down

0 comments on commit efa41b4

Please sign in to comment.