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 2021/11/28 05:37:37 UTC

[GitHub] [arrow-datafusion] tobyhede opened a new pull request #1371: WIP: fix issues in function definitions

tobyhede opened a new pull request #1371:
URL: https://github.com/apache/arrow-datafusion/pull/1371


   # Which issue does this PR close?
   Addresses #1364 #1173 
   
   Several of the built-in function definitions are not setup correctly and the functions cannot actually be used at all. 
   This is the start of some changes to ensure that functions can be passed the correct parameters. 
   
   All seeks to address a gap in the test suite and examples and documentation. 
   
   There are not many tests using the internal functions, and there are no tests at all using functions with dataframes (probably because many of the functions don't actually work and can't be called). 
   
   
   


-- 
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] tobyhede closed pull request #1371: WIP: fix issues in function definitions

Posted by GitBox <gi...@apache.org>.
tobyhede closed pull request #1371:
URL: https://github.com/apache/arrow-datafusion/pull/1371


   


-- 
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 #1371: WIP: fix issues in function definitions

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


   > It's taking me a bit longer than anticipated - there are a range of function arities to consider.
   
   This is the story of my life with software development 😆  maybe more so with Rust


-- 
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] tobyhede commented on pull request #1371: WIP: fix issues in function definitions

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


   It's taking me a bit longer than anticipated - there are a range of function arities to consider. 
   I am on the right track though, so I'll close this and reopen with new code. 


-- 
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] tobyhede commented on a change in pull request #1371: WIP: fix issues in function definitions

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



##########
File path: datafusion/tests/dataframe.rs
##########
@@ -77,3 +77,37 @@ async fn join() -> Result<()> {
 
     Ok(())
 }
+
+
+#[tokio::test]
+async fn test_starts_with() -> Result<()> {
+    let schema = Arc::new(Schema::new(vec![
+        Field::new("a", DataType::Utf8, false),
+        Field::new("b", DataType::Int32, false),
+    ]));
+
+    // define data.
+    let batch = RecordBatch::try_new(
+        schema.clone(),
+        vec![
+            Arc::new(StringArray::from(vec!["abcdef", "abc123", "ab_def", "a_bcdef"])),
+            Arc::new(Int32Array::from(vec![1, 10, 10, 100])),
+        ],
+    )?;
+
+    let mut ctx = ExecutionContext::new();
+
+    let table = MemTable::try_new(schema, vec![vec![batch]])?;
+
+    ctx.register_table("aa", Arc::new(table))?;
+
+    let df = ctx.table("aa")?;
+
+    let df = df.filter( starts_with(col("a"), lit("abc")))?;
+
+    let batches = df.collect().await?;

Review comment:
       Thanks @alamb - I discovered that one in my digging, so much easier than what I was attempting to do.
   Working on some of the other functions atm.




-- 
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 #1371: WIP: fix issues in function definitions

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



##########
File path: datafusion/tests/dataframe.rs
##########
@@ -77,3 +77,37 @@ async fn join() -> Result<()> {
 
     Ok(())
 }
+
+
+#[tokio::test]
+async fn test_starts_with() -> Result<()> {
+    let schema = Arc::new(Schema::new(vec![
+        Field::new("a", DataType::Utf8, false),
+        Field::new("b", DataType::Int32, false),
+    ]));
+
+    // define data.
+    let batch = RecordBatch::try_new(
+        schema.clone(),
+        vec![
+            Arc::new(StringArray::from(vec!["abcdef", "abc123", "ab_def", "a_bcdef"])),
+            Arc::new(Int32Array::from(vec![1, 10, 10, 100])),
+        ],
+    )?;
+
+    let mut ctx = ExecutionContext::new();
+
+    let table = MemTable::try_new(schema, vec![vec![batch]])?;
+
+    ctx.register_table("aa", Arc::new(table))?;
+
+    let df = ctx.table("aa")?;
+
+    let df = df.filter( starts_with(col("a"), lit("abc")))?;
+
+    let batches = df.collect().await?;

Review comment:
       A common way to compare the output of running a query with expected answers  is  using `assert_batches_eq`, for example https://github.com/apache/arrow-datafusion/blob/15db29153aefc9b759ec03e6eeab8cb9ebf87781/datafusion/tests/sql.rs#L272-L286




-- 
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 #1371: WIP: fix issues in function definitions

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


   Hi @tobyhede I am checking in on this PR -- any chance you will be able to complete it any time soon?


-- 
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