You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Jiashu-Hu (via GitHub)" <gi...@apache.org> on 2025/03/20 05:29:47 UTC
[PR] added explaination for Schema and DFSchema to documentation [datafusion]
Jiashu-Hu opened a new pull request, #15329:
URL: https://github.com/apache/datafusion/pull/15329
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
-->
- Closes [#7724](https://github.com/apache/datafusion/issues/7724) .
## Rationale for this change
Added some description about DFSchema and Schema for make user easy to understanding and easy to use
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
## What changes are included in this PR?
Updated documentation we a new section "Arrow Schema and DataFusion DFSchema"
<!--
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 these changes tested?
No need to test
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
Yes, documentation is 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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #15329:
URL: https://github.com/apache/datafusion/pull/15329#discussion_r2006094913
##########
docs/source/library-user-guide/working-with-exprs.md:
##########
@@ -50,6 +50,29 @@ As another example, the SQL expression `a + b * c` would be represented as an `E
As the writer of a library, you can use `Expr`s to represent computations that you want to perform. This guide will walk you through how to make your own scalar UDF as an `Expr` and how to rewrite `Expr`s to inline the simple UDF.
+## Arrow Schema and DataFusion DFSchema
+
+Schema and DFSchema are both exist in datafusion because `Schema` provides a lightweight structure for defining data, and `DFSchema` extends it with extra information. This makes the engine could handle both simple data definitions and complex query scenarios efficiently.
Review Comment:
I would probably rephrase it saying the DFSchema is a wrapper on top of Arrow schema, extending the latter to support DF features which missing in Arrow Schema, like qualifier support, metadata, functional dependencies
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead merged PR #15329:
URL: https://github.com/apache/datafusion/pull/15329
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #15329:
URL: https://github.com/apache/datafusion/pull/15329#discussion_r2006103754
##########
docs/source/library-user-guide/working-with-exprs.md:
##########
@@ -50,6 +50,29 @@ As another example, the SQL expression `a + b * c` would be represented as an `E
As the writer of a library, you can use `Expr`s to represent computations that you want to perform. This guide will walk you through how to make your own scalar UDF as an `Expr` and how to rewrite `Expr`s to inline the simple UDF.
+## Arrow Schema and DataFusion DFSchema
+
+Schema and DFSchema are both exist in datafusion because `Schema` provides a lightweight structure for defining data, and `DFSchema` extends it with extra information. This makes the engine could handle both simple data definitions and complex query scenarios efficiently.
+
+### Difference between Schema and DFSchema
+
+- Schema: A fundamental component of Apache Arrow, `Schema` defines a dataset's structure, specifying column names and their data types.
+
+ > Please see [Struct Schema](https://docs.rs/arrow-schema/54.2.1/arrow_schema/struct.Schema.html) for a detailed document of Arrow Schema.
+
+- DFSchema: Extending `Schema`, `DFSchema` incorporates qualifiers such as table names, enabling it to carry additional context when required. This is particularly valuable for managing queries across multiple tables.
+ > Please see [Struct DFSchema](https://docs.rs/datafusion/latest/datafusion/common/struct.DFSchema.html) for a detailed document of DFSchema.
+
+### How to convert between Schema and DFSchema
+
+From Schema to DFSchema: Use `DFSchema::try_from_qualified_schema` with a table name and original schema. See example below:
+
+> let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema).unwrap();
+
Review Comment:
For conversion it is worth to point to DFSchema link documentation https://docs.rs/datafusion/latest/datafusion/common/struct.DFSchema.html#converting-back-to-arrow-schema
Other conversion methods which are suitable for users it is nice to document in the rust doc
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "Jiashu-Hu (via GitHub)" <gi...@apache.org>.
Jiashu-Hu commented on code in PR #15329:
URL: https://github.com/apache/datafusion/pull/15329#discussion_r2006264327
##########
docs/source/library-user-guide/working-with-exprs.md:
##########
@@ -50,6 +50,29 @@ As another example, the SQL expression `a + b * c` would be represented as an `E
As the writer of a library, you can use `Expr`s to represent computations that you want to perform. This guide will walk you through how to make your own scalar UDF as an `Expr` and how to rewrite `Expr`s to inline the simple UDF.
+## Arrow Schema and DataFusion DFSchema
+
+Schema and DFSchema are both exist in datafusion because `Schema` provides a lightweight structure for defining data, and `DFSchema` extends it with extra information. This makes the engine could handle both simple data definitions and complex query scenarios efficiently.
+
+### Difference between Schema and DFSchema
+
+- Schema: A fundamental component of Apache Arrow, `Schema` defines a dataset's structure, specifying column names and their data types.
+
+ > Please see [Struct Schema](https://docs.rs/arrow-schema/54.2.1/arrow_schema/struct.Schema.html) for a detailed document of Arrow Schema.
+
+- DFSchema: Extending `Schema`, `DFSchema` incorporates qualifiers such as table names, enabling it to carry additional context when required. This is particularly valuable for managing queries across multiple tables.
+ > Please see [Struct DFSchema](https://docs.rs/datafusion/latest/datafusion/common/struct.DFSchema.html) for a detailed document of DFSchema.
+
+### How to convert between Schema and DFSchema
+
+From Schema to DFSchema: Use `DFSchema::try_from_qualified_schema` with a table name and original schema. See example below:
+
+> let df_schema = DFSchema::try_from_qualified_schema("t1", &arrow_schema).unwrap();
+
Review Comment:
Hi Comphead, thank you for your review! Your advice is really helpful, I've made changes based on your advice and pushed a new version for you to review.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #15329:
URL: https://github.com/apache/datafusion/pull/15329#discussion_r2007928627
##########
docs/source/library-user-guide/working-with-exprs.md:
##########
@@ -50,6 +50,25 @@ As another example, the SQL expression `a + b * c` would be represented as an `E
As the writer of a library, you can use `Expr`s to represent computations that you want to perform. This guide will walk you through how to make your own scalar UDF as an `Expr` and how to rewrite `Expr`s to inline the simple UDF.
+## Arrow Schema and DataFusion DFSchema
+
+Schema and DFSchema are both exist in datafusion because `Schema` provides a lightweight structure for defining data, and `DFSchema` extends it with extra information. This makes the engine could handle both simple data definitions and complex query scenarios efficiently.
Review Comment:
```suggestion
Apache Arrow `Schema` provides a lightweight structure for defining data, and Apache Datafusion`DFSchema` extends it with extra information such as column qualifiers and functional dependencies. Column qualifiers are multi part path to the table e.g table, schema, catalog. Functional Dependency is the relationship between attributes(characteristics) of a table related to each other.
```
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] added explaination for Schema and DFSchema to documentation [datafusion]
Posted by "Jiashu-Hu (via GitHub)" <gi...@apache.org>.
Jiashu-Hu commented on code in PR #15329:
URL: https://github.com/apache/datafusion/pull/15329#discussion_r2007966257
##########
docs/source/library-user-guide/working-with-exprs.md:
##########
@@ -50,6 +50,25 @@ As another example, the SQL expression `a + b * c` would be represented as an `E
As the writer of a library, you can use `Expr`s to represent computations that you want to perform. This guide will walk you through how to make your own scalar UDF as an `Expr` and how to rewrite `Expr`s to inline the simple UDF.
+## Arrow Schema and DataFusion DFSchema
+
+Schema and DFSchema are both exist in datafusion because `Schema` provides a lightweight structure for defining data, and `DFSchema` extends it with extra information. This makes the engine could handle both simple data definitions and complex query scenarios efficiently.
Review Comment:
Hi comphead, thanks for your review! Look's much better! seems you've updated the file, if everything looks good we may start this merge
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org