You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/03/10 10:40:58 UTC

[GitHub] [arrow-datafusion] Ted-Jiang opened a new pull request #1974: Implement EXTRACT expression with week, month, day, hour

Ted-Jiang opened a new pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974


   # Which issue does this PR close?
   
   
   Closes #1896.
   
    # Rationale for this change
   Already add compute method in `arrow-rs`, will fix `EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))` in `sqlparser`
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] Ted-Jiang commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r824336107



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       @liukun4515 @liukun4515  @mobuchowski   i would like to add this ,  it's a good chance to start familiar `sqlparser`
   😊




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] liukun4515 commented on pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#issuecomment-1064690651


   Sorry for the later response.
   @Ted-Jiang 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] Ted-Jiang commented on pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
Ted-Jiang commented on pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#issuecomment-1063916793


   @alamb @liukun4515 PTAL


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] liukun4515 commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r824323294



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       @Ted-Jiang Maybe you can file a pr to fix this.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] liukun4515 commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r824420558



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       https://github.com/sqlparser-rs/sqlparser-rs/pull/436




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] mobuchowski commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
mobuchowski commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r823853721



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       Don't worry, that's not how I received it :)

##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       Don't worry, that's not how I received it 🙂 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r823815215



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       I didn't meant to make you feel bad @mobuchowski  -- mostly I was trying to give you props for adding stuff to sqlparser ;)
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] mobuchowski commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
mobuchowski commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r823811033



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       Can't believe I missed it... 😞 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
alamb commented on pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#issuecomment-1065689062


   Thanks @Ted-Jiang  -- I hope to spend some non trivial amount of time this weekend reviewing and merging PRs


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb commented on a change in pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
alamb commented on a change in pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974#discussion_r823778665



##########
File path: datafusion/tests/sql/expr.rs
##########
@@ -714,17 +714,36 @@ async fn in_list_array() -> Result<()> {
 
 #[tokio::test]
 async fn test_extract_date_part() -> Result<()> {
-    test_expression!("date_part('hour', CAST('2020-01-01' AS DATE))", "0");
-    test_expression!("EXTRACT(HOUR FROM CAST('2020-01-01' AS DATE))", "0");
-    test_expression!(
-        "EXTRACT(HOUR FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
-        "12"
-    );
     test_expression!("date_part('YEAR', CAST('2000-01-01' AS DATE))", "2000");
     test_expression!(
         "EXTRACT(year FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
         "2020"
     );
+    test_expression!("date_part('MONTH', CAST('2000-01-01' AS DATE))", "1");
+    test_expression!(
+        "EXTRACT(month FROM to_timestamp('2020-09-08T12:00:00+00:00'))",
+        "9"
+    );
+    test_expression!("date_part('WEEK', CAST('2003-01-01' AS DATE))", "1");
+
+    //TODO Creating logical plan for 'SELECT EXTRACT(WEEK FROM to_timestamp('2020-09-08T12:00:00+00:00'))'

Review comment:
       Many keywords got added in  https://github.com/sqlparser-rs/sqlparser-rs/pull/427 from @mobuchowski (👋 ) but sadly it seems to be missing `week` 😭 
   
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [arrow-datafusion] alamb merged pull request #1974: Implement EXTRACT expression with week, month, day, hour

Posted by GitBox <gi...@apache.org>.
alamb merged pull request #1974:
URL: https://github.com/apache/arrow-datafusion/pull/1974


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org