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/10/05 19:57:27 UTC
[GitHub] [arrow-datafusion] hengfeiyang opened a new issue, #3682: Field names containing periods such as f.c cannot work
hengfeiyang opened a new issue, #3682:
URL: https://github.com/apache/arrow-datafusion/issues/3682
**Describe the bug**
Field names containing periods such as f.c cannot work.
**To Reproduce**
Steps to reproduce the behavior:
```rust
use std::sync::Arc;
use datafusion::arrow::array::Int32Array;
use datafusion::arrow::datatypes::{DataType, Field, Schema};
use datafusion::arrow::record_batch::RecordBatch;
use datafusion::datasource::MemTable;
use datafusion::error::Result;
use datafusion::from_slice::FromSlice;
use datafusion::prelude::{col, lit, SessionContext};
/// This example demonstrates how to use the DataFrame API against in-memory data.
#[tokio::main]
async fn main() -> Result<()> {
// define a schema.
let schema = Arc::new(Schema::new(vec![Field::new("f.c", DataType::Int32, false)]));
// define data.
let batch = RecordBatch::try_new(
schema.clone(),
vec![Arc::new(Int32Array::from_slice(&[1, 10, 10, 100]))],
)?;
// declare a new context. In spark API, this corresponds to a new spark SQLsession
let ctx = SessionContext::new();
// declare a table in memory. In spark API, this corresponds to createDataFrame(...).
let provider = MemTable::try_new(schema.clone(), vec![vec![batch]])?;
ctx.register_table("t", Arc::new(provider))?;
let df = ctx.table("t")?;
// construct an expression corresponding to "SELECT * FROM t WHERE f.c = 10" in SQL
let filter = col("f.c").eq(lit(10));
let df = df.filter(filter)?;
// print the results
df.show().await?;
Ok(())
}
```
**Expected behavior**
expect it can work.
**Additional context**
DataFusion 12.0
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow-datafusion] hengfeiyang commented on issue #3682: Field names containing periods such as f.c cannot work
Posted by GitBox <gi...@apache.org>.
hengfeiyang commented on issue #3682:
URL: https://github.com/apache/arrow-datafusion/issues/3682#issuecomment-1265655708
@alamb In SQL layer it can work, but in DataFrame it can't work.
--
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 issue #3682: Field names containing periods such as f.c cannot work
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #3682:
URL: https://github.com/apache/arrow-datafusion/issues/3682#issuecomment-1265654378
Does this work if you run a query (note the double quotes `"` around `f.c`)
```sql
SELECT * FROM t WHERE "f.c" = 10
```
--
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 issue #3682: Field names containing periods such as f.c cannot work
Posted by GitBox <gi...@apache.org>.
alamb commented on issue #3682:
URL: https://github.com/apache/arrow-datafusion/issues/3682#issuecomment-1265690172
@hengfeiyang I think you may have to create an explicit column reference -- for example instead of `col("f.c")` perhaps you could do something like
```rust
Expr::Column(Column {
relation: None,
name: "f.c".into()
})
```
--
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] hengfeiyang commented on issue #3682: Field names containing periods such as f.c cannot work
Posted by GitBox <gi...@apache.org>.
hengfeiyang commented on issue #3682:
URL: https://github.com/apache/arrow-datafusion/issues/3682#issuecomment-1265719287
@alamb Thanks, the filter can work now. But I am real work is `with_column`, I updated my example code above and added a line:
```
let df = df.with_column("f2", lit("hello"))?;
```
You can have a try, this line will cause the error too, Do you have any idea? thank you.
--
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 closed issue #3682: Field names containing periods such as f.c cannot work
Posted by GitBox <gi...@apache.org>.
alamb closed issue #3682: Field names containing periods such as f.c cannot work
URL: https://github.com/apache/arrow-datafusion/issues/3682
--
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