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/20 16:14:22 UTC
[GitHub] [arrow-datafusion] avantgardnerio opened a new pull request, #3907: Add serde for plans with tables from `TableProviderFactory`s
avantgardnerio opened a new pull request, #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907
# Which issue does this PR close?
Closes #3906.
# Rationale for this change
Described in issue.
# What changes are included in this PR?
Described in issue.
# Are there any user-facing changes?
Plans relying on `TableProviderFatory`s can be shipped.
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003695455
##########
datafusion/core/src/execution/context.rs:
##########
@@ -418,19 +418,18 @@ impl SessionContext {
cmd: &CreateExternalTable,
) -> Result<Arc<DataFrame>> {
let state = self.state.read().clone();
+ let file_type = cmd.file_type.to_lowercase();
Review Comment:
If there is an assumption that the file_types are always lower case in `table_factories` perhaps would it make sense to update the comment to that effect?
https://github.com/apache/arrow-datafusion/blob/6e0097d35391fea0d57c1d2ecfdef18437f681f4/datafusion/core/src/execution/runtime_env.rs#L48
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
Review Comment:
Is this trait a left over? I didn't think this PR added support for serializing / deserializing physical plans
##########
datafusion/proto/src/lib.rs:
##########
@@ -129,6 +135,26 @@ mod roundtrip_tests {
Ok(())
}
+ #[tokio::test]
+ async fn roundtrip_custom_tables() -> Result<(), DataFusionError> {
+ let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> =
+ HashMap::new();
+ table_factories.insert("deltatable".to_string(), Arc::new(TestTableFactory {}));
+ let cfg = RuntimeConfig::new().with_table_factories(table_factories);
Review Comment:
Yeah -- this makes the most sense -- basically the system which made the table provider needs to provide details on how to serialize/deserialize it
##########
datafusion/proto/src/bytes/mod.rs:
##########
@@ -180,6 +188,27 @@ impl LogicalExtensionCodec for DefaultExtensionCodec {
"No extension codec provided".to_string(),
))
}
+
+ async fn try_decode_table_provider(
+ &self,
+ _buf: &[u8],
+ _schema: SchemaRef,
+ _ctx: &SessionContext,
+ ) -> std::result::Result<Arc<dyn TableProvider>, DataFusionError> {
+ Err(DataFusionError::NotImplemented(
+ "No extension codec provided".to_string(),
Review Comment:
```suggestion
"No codec provided to for TableProviders".to_string(),
```
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -625,11 +714,11 @@ impl AsLogicalPlan for LogicalPlanNode {
builder.build()
}
LogicalPlanType::Union(union) => {
- let mut input_plans: Vec<LogicalPlan> = union
- .inputs
- .iter()
- .map(|i| i.try_into_logical_plan(ctx, extension_codec))
- .collect::<Result<_, DataFusionError>>()?;
+ let mut input_plans: Vec<LogicalPlan> = vec![];
Review Comment:
making something async and having to switch from a functional style is unfortunate -- one can also make streams but that syntax (well really the errors if you get it wrong) becomes wild
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
+ fn try_decode(
+ &self,
+ buf: &[u8],
+ inputs: &[Arc<dyn ExecutionPlan>],
+ registry: &dyn FunctionRegistry,
+ ) -> Result<Arc<dyn ExecutionPlan>, DataFusionError>;
+
+ fn try_encode(
+ &self,
+ node: Arc<dyn ExecutionPlan>,
+ buf: &mut Vec<u8>,
+ ) -> Result<(), DataFusionError>;
+}
+
+#[async_trait]
pub trait LogicalExtensionCodec: Debug + Send + Sync {
Review Comment:
We wonder if we should rename `LogicalExtensionCodec` to something more generic, but we can do that in the future perhaps
##########
datafusion/proto/src/bytes/mod.rs:
##########
@@ -180,6 +188,27 @@ impl LogicalExtensionCodec for DefaultExtensionCodec {
"No extension codec provided".to_string(),
))
}
+
+ async fn try_decode_table_provider(
+ &self,
+ _buf: &[u8],
+ _schema: SchemaRef,
+ _ctx: &SessionContext,
+ ) -> std::result::Result<Arc<dyn TableProvider>, DataFusionError> {
+ Err(DataFusionError::NotImplemented(
+ "No extension codec provided".to_string(),
+ ))
+ }
+
+ fn try_encode_table_provider(
+ &self,
+ _node: Arc<dyn TableProvider>,
+ _buf: &mut Vec<u8>,
+ ) -> std::result::Result<(), DataFusionError> {
+ Err(DataFusionError::NotImplemented(
+ "No extension codec provided".to_string(),
Review Comment:
```suggestion
"No codec provided to for TableProviders".to_string(),
```
##########
datafusion/proto/src/bytes/mod.rs:
##########
@@ -132,37 +136,41 @@ pub fn logical_plan_to_bytes_with_extension_codec(
/// Deserialize a LogicalPlan from json
#[cfg(feature = "json")]
-pub fn logical_plan_from_json(json: &str, ctx: &SessionContext) -> Result<LogicalPlan> {
+pub async fn logical_plan_from_json(
+ json: &str,
+ ctx: &SessionContext,
+) -> Result<LogicalPlan> {
let back: protobuf::LogicalPlanNode = serde_json::from_str(json)
.map_err(|e| DataFusionError::Plan(format!("Error serializing plan: {}", e)))?;
let extension_codec = DefaultExtensionCodec {};
- back.try_into_logical_plan(ctx, &extension_codec)
+ back.try_into_logical_plan(ctx, &extension_codec).await
}
/// Deserialize a LogicalPlan from bytes
-pub fn logical_plan_from_bytes(
+pub async fn logical_plan_from_bytes(
Review Comment:
It makes sense to me that these functions must become `async` in order to (potentially) instantiate a table provider 👍
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003724353
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
Review Comment:
It was moved out of Ballista and into datafusion. I would think being a libarary, DataFusion would have to represent both physical and logical plans in memory, but not serialize them. For reasons which I am not yet familiar, DataFusion contains the code to serialize logical plans, but Ballista is in charge of serializing physical plans, so this PhysicalExtensionCodec was defined there, and this PR moves it into DataFusion.
As for the reason why, libraries like delta-rs will want to extend these traits (TableProviderFactory, LogicalExtensionCodec, and PhysicalExtensionCodec) to provide their own tables to executables up the chain like Ballista, and to do this, it needs to be defined below them in the dependency tree so they can implement it... see https://github.com/spaceandtimelabs/delta-rs/blob/379558798b644d3a269514a99b322850d5d4b5a6/rust/src/delta_datafusion.rs#L754 for an example.
Eventually this series of PRs will end in a Ballista PR with a `deltalake` feature and if specified it will bring in delta's implementation of the above traits and make delta tables registerable in SQL at runtime.
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001006288
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> I don't think this would fit with the goal, as datafusion would have to include types at compile time for each table, i.e. we'd have to make a compile time dependency on delta-rs which itself has a compile-time dependency on datafusion already.
Yeah, I think the "issue" is that delta-rs will have to provide its own serialization / deserialization
--
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 #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb merged PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907
--
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] yahoNanJing commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
yahoNanJing commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1289995355
Hi @alamb @avantgardnerio, why we change the interface of `try_into_logical_plan` to be async?
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003680432
##########
datafusion/proto/src/lib.rs:
##########
@@ -129,6 +135,26 @@ mod roundtrip_tests {
Ok(())
}
+ #[tokio::test]
+ async fn roundtrip_custom_tables() -> Result<(), DataFusionError> {
+ let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> =
+ HashMap::new();
+ table_factories.insert("deltatable".to_string(), Arc::new(TestTableFactory {}));
+ let cfg = RuntimeConfig::new().with_table_factories(table_factories);
Review Comment:
I think that is perfect
--
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] xudong963 commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
xudong963 commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003536621
##########
datafusion/core/src/datasource/datasource.rs:
##########
@@ -80,5 +80,5 @@ pub trait TableProvider: Sync + Send {
#[async_trait]
pub trait TableProviderFactory: Sync + Send {
/// Create a TableProvider given name and url
Review Comment:
```suggestion
/// Create a TableProvider with the given url
```
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000965184
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> I don't fully understand this proposal
That delta PR really explains what I'm trying to do. Unfortunately the end goal spans datafusion, delta-rs & ballista, so it's hard to convey. And I'm open to doing it simpler ways if they exist and fulfill the broader goal of supporting table types unknown to datafusion (i.e. delta, but possibly others).
> the client code needs to get the concrete TableProvider
As long as the deserializing node also has the `TableProviderFactory` registered, it can get a concrete one created. The CustomTable is just a wrapper that contains enough information to get it instantiated by the factory.
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000965184
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> I don't fully understand this proposal
That [delta PR](https://github.com/delta-io/delta-rs/pull/892) really explains what I'm trying to do. Unfortunately the end goal spans datafusion, delta-rs & ballista, so it's hard to convey. And I'm open to doing it simpler ways if they exist and fulfill the broader goal of supporting table types unknown to datafusion (i.e. delta, but possibly others).
> the client code needs to get the concrete TableProvider
As long as the deserializing node also has the `TableProviderFactory` registered, it can get a concrete one created. The CustomTable is just a wrapper that contains enough information to get it instantiated by the factory.
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003781950
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
Review Comment:
I think putting physical plan serde for structs defined in DataFusion makes lots of sense to me 👍
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000967508
##########
datafusion/proto/src/lib.rs:
##########
@@ -129,6 +135,26 @@ mod roundtrip_tests {
Ok(())
}
+ #[tokio::test]
+ async fn roundtrip_custom_tables() -> Result<(), DataFusionError> {
+ let mut table_factories: HashMap<String, Arc<dyn TableProviderFactory>> =
+ HashMap::new();
+ table_factories.insert("deltatable".to_string(), Arc::new(TestTableFactory {}));
+ let cfg = RuntimeConfig::new().with_table_factories(table_factories);
Review Comment:
As long as the deserializing side has the same `TableFactory` registered, this will 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 pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1290849552
When we reach a resolution it would be great to add some comments with the rationale of which way we decided (`async` or non `async`) as well
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001020991
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> will have to provide its own serialization / deserialization
That works for me!
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001177756
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
Actually, it looks like we are conflating the `scan` data with the `TableProvider` data when we serialize. I split them out in `is a stub for testing`.
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001177756
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
Actually, it looks like we are conflating the `scan` data with the `TableProvider` data when we serialize. I split them out in `CustomTableScanNode`.
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000978682
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
```
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
// ...
} else {
```
I don't think this would fit with the goal, as datafusion would have to include types at compile time for each table, i.e. we'd have to make a compile time dependency on delta-rs which itself has a compile-time dependency on datafusion already.
--
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] ursabot commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1290951141
Benchmark runs are scheduled for baseline = e1f866e99c6648fb72319d39c776f37a3c8db1d2 and contender = 9595b8d60c9c40aefc514362264c7fa570b563a6. 9595b8d60c9c40aefc514362264c7fa570b563a6 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/fd1b70bbe554448180d4c797782826a9...3e14cb2ed9504dfe982bce57e5a751e0/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/d1e61501bc8a4550828ae1b98ad9c15c...928f6f547bae4be292648d37e06b13bb/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/23025baff8c14264bccdf122ec325992...47d4fbb7ee254432a38db1fffd7e7a48/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/fcd03f5cbe954efcbc994ec252479b90...e9674661c870495bbe9c978115fb3e41/)
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000979661
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> have to include types at compile time
Unless that `downcast_ref::` trick works on traits as well as structs.
--
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] avantgardnerio commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1285934826
> at a loss as to how/where to test this
I added a roundtrip test. I think this covers 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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000968450
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
> I wonder if we can follow the same model here
Reviewing...
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000956863
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
So this seems to be the key issue -- if `source` isn't some type that DataFusion knows about it can't do a useful job serializing it.
I don't fully understand how a `CustomTable` struct will help -- at some point the client code needs to get the concrete `TableProvider`, not a `CustomTable`.
I think there was a similar issue serializing "extensions" for which @thinkharderdev added
```rust
pub trait LogicalExtensionCodec: Debug + Send + Sync {
```
I wonder if we can follow the same model here , something like add `LogicalExtensionCodec::try_encoded_table_provider` and `LogicalExtensionCodec::try_decode_table_provider`
```rust
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
// ...
} else {
// delegate to provided extension codec:
extension_codec.try_encode_table_provider(
table_name,
source,
filters,
projection,
);
}
```
--
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] avantgardnerio commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1285824467
I'm at a loss as to how/where to test this. It makes things work in other repos by definition (i.e. https://github.com/delta-io/delta-rs/pull/892). I think I just need to make a NoOpTableProvider and write a test that does serde on it? (@andygrove @alamb )
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001178707
##########
datafusion/proto/proto/datafusion.proto:
##########
@@ -118,6 +119,15 @@ message ViewTableScanNode {
string definition = 5;
}
+// Logical Plan to Scan a CustomTableProvider registered at runtime
+message CustomTableScanNode {
+ string table_name = 1;
+ ProjectionColumns projection = 2;
+ datafusion.Schema schema = 3;
+ repeated datafusion.LogicalExprNode filters = 4;
+ bytes custom_table_data = 5;
Review Comment:
The above 4 fields are unrelated to the `TableProvider` - they come from the `scan`. The `ListingTableScan` doesn't have this problem because it can happily combine the two logical units into one message, but unless we want each custom table type to reimplement this logic, we should probably keep it here.
--
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] avantgardnerio commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1289639024
Thanks everyone, on to the next PR! :D
--
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] avantgardnerio commented on pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1290724589
> why we change the interface
I left [a comment](https://github.com/apache/arrow-datafusion/pull/3955#issuecomment-1290713704) on the other PR... let's have the discussion there (so there's one place to track).
--
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] andygrove commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003820875
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
Review Comment:
I filed https://github.com/apache/arrow-datafusion/issues/3949 for 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] andygrove commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
andygrove commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1003739700
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -93,6 +100,22 @@ pub trait AsLogicalPlan: Debug + Send + Sync + Clone {
Self: Sized;
}
+pub trait PhysicalExtensionCodec: Debug + Send + Sync {
Review Comment:
It is odd that we ended up with logical plan serde in DataFusion and physical plan serde in Ballista. I could see an argument for moving the physical plan serde into DataFusion, with Ballista extending this for its custom physical operators. @alamb What do you think?
--
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 #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#issuecomment-1289635738
Thanks everyone who helped make this PR -- both the code and reviews 🚀
--
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 diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1004721301
##########
datafusion/proto/src/bytes/mod.rs:
##########
@@ -132,37 +136,41 @@ pub fn logical_plan_to_bytes_with_extension_codec(
/// Deserialize a LogicalPlan from json
#[cfg(feature = "json")]
-pub fn logical_plan_from_json(json: &str, ctx: &SessionContext) -> Result<LogicalPlan> {
+pub async fn logical_plan_from_json(
+ json: &str,
+ ctx: &SessionContext,
+) -> Result<LogicalPlan> {
let back: protobuf::LogicalPlanNode = serde_json::from_str(json)
.map_err(|e| DataFusionError::Plan(format!("Error serializing plan: {}", e)))?;
let extension_codec = DefaultExtensionCodec {};
- back.try_into_logical_plan(ctx, &extension_codec)
+ back.try_into_logical_plan(ctx, &extension_codec).await
}
/// Deserialize a LogicalPlan from bytes
-pub fn logical_plan_from_bytes(
+pub async fn logical_plan_from_bytes(
Review Comment:
To follow up -- becomes `async` so that a table provider can be instantiated. This table provider, such as delta-rs, might have to do remote IO
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1001032741
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
I think we'll need something like:
```
message LogicalPlanNode {
oneof LogicalPlanType {
CustomTableScanNode custom_scan = 25;
```
and
```
message CustomTableScanNode {
bytes custom_table_data = 1;
}
```
--
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] avantgardnerio commented on a diff in pull request #3907: Add serde for plans with tables from `TableProviderFactory`s
Posted by GitBox <gi...@apache.org>.
avantgardnerio commented on code in PR #3907:
URL: https://github.com/apache/arrow-datafusion/pull/3907#discussion_r1000989863
##########
datafusion/proto/src/logical_plan.rs:
##########
@@ -760,55 +804,21 @@ impl AsLogicalPlan for LogicalPlanNode {
.collect::<Result<Vec<_>, _>>()?;
if let Some(listing_table) = source.downcast_ref::<ListingTable>() {
- let any = listing_table.options().format.as_any();
- let file_format_type = if let Some(parquet) =
- any.downcast_ref::<ParquetFormat>()
- {
- FileFormatType::Parquet(protobuf::ParquetFormat {
- enable_pruning: parquet.enable_pruning(),
- })
- } else if let Some(csv) = any.downcast_ref::<CsvFormat>() {
- FileFormatType::Csv(protobuf::CsvFormat {
- delimiter: byte_to_string(csv.delimiter())?,
- has_header: csv.has_header(),
- })
- } else if any.is::<AvroFormat>() {
- FileFormatType::Avro(protobuf::AvroFormat {})
- } else {
- return Err(proto_error(format!(
- "Error converting file format, {:?} is invalid as a datafusion foramt.",
- listing_table.options().format
- )));
- };
- Ok(protobuf::LogicalPlanNode {
- logical_plan_type: Some(LogicalPlanType::ListingScan(
- protobuf::ListingTableScanNode {
- file_format_type: Some(file_format_type),
- table_name: table_name.to_owned(),
- collect_stat: listing_table.options().collect_stat,
- file_extension: listing_table
- .options()
- .file_extension
- .clone(),
- table_partition_cols: listing_table
- .options()
- .table_partition_cols
- .clone(),
- paths: listing_table
- .table_paths()
- .iter()
- .map(|x| x.to_string())
- .collect(),
- schema: Some(schema),
- projection,
- filters,
- target_partitions: listing_table
- .options()
- .target_partitions
- as u32,
- },
- )),
- })
+ Self::serialize_listing_table(
+ table_name,
+ projection,
+ schema,
+ filters,
+ listing_table,
+ )
+ } else if let Some(custom_table) = source.downcast_ref::<CustomTable>() {
Review Comment:
I see it works via the `dyn Any` trait, so that seems okay. I was worried about having to add `delta-rs` stuff to the `datafusion.proto`, but I see `pub struct TopKPlanProto` gets away without modifying the protobuf definition. If you think this will work @alamb I'll start work on another PR doing it with the codec instead.
--
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