You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jaylmiller (via GitHub)" <gi...@apache.org> on 2023/02/18 01:20:50 UTC
[GitHub] [arrow-datafusion] jaylmiller opened a new pull request, #5326: Add example of catalog API usage (#5291)
jaylmiller opened a new pull request, #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326
# Which issue does this PR close?
#5291 (does not close)
# Rationale for this change
A simple example can help users figure out how to use DataFusion's catalog API.
# What changes are included in this PR?
Just the example.
# Are these changes tested?
n/a
# Are there any user-facing changes?
n/a
--
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 #5326: Add example of catalog API usage (#5291)
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326#issuecomment-1445355253
The CI failure seems unrelated to this PR so merging this one in. THanks @jaylmiller
https://github.com/apache/arrow-datafusion/actions/runs/4212165207/jobs/7311048020
--
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 #5326: Add example of catalog API usage (#5291)
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326
--
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] jaylmiller commented on a diff in pull request #5326: Add example of catalog API usage (#5291)
Posted by "jaylmiller (via GitHub)" <gi...@apache.org>.
jaylmiller commented on code in PR #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326#discussion_r1111059678
##########
datafusion-examples/examples/catalog.rs:
##########
@@ -0,0 +1,287 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Simple example of a catalog/schema implementation.
+//!
+//! Example requires git submodules to be initialized in repo as it uses data from
+//! the `parquet-testing` repo.
+use async_trait::async_trait;
+use datafusion::{
+ arrow::util::pretty,
+ catalog::{
+ catalog::{CatalogList, CatalogProvider},
+ schema::SchemaProvider,
+ },
+ datasource::{
+ file_format::{csv::CsvFormat, parquet::ParquetFormat, FileFormat},
+ listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl},
+ TableProvider,
+ },
+ error::Result,
+ execution::context::SessionState,
+ prelude::SessionContext,
+};
+use std::sync::RwLock;
+use std::{
+ any::Any,
+ collections::HashMap,
+ path::{Path, PathBuf},
+ sync::Arc,
+};
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let repo_dir = std::fs::canonicalize(
+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+ // parent dir of datafusion-examples = repo root
+ .join(".."),
+ )
+ .unwrap();
+ let mut ctx = SessionContext::new();
+ let state = ctx.state();
+ let catlist = Arc::new(CustomCatalogList::new());
+ // use our custom catalog list for context. each context has a single catalog list.
+ // context will by default have MemoryCatalogList
+ ctx.register_catalog_list(catlist.clone());
+
+ // intitialize our catalog and schemas
+ let catalog = DirCatalog::new();
+ let parquet_schema = DirSchema::create(
+ &state,
+ DirSchemaOpts {
+ format: Arc::new(ParquetFormat::default()),
+ dir: &repo_dir.join("parquet-testing").join("data"),
+ ext: "parquet",
+ },
+ )
+ .await?;
+ let csv_schema = DirSchema::create(
+ &state,
+ DirSchemaOpts {
+ format: Arc::new(CsvFormat::default()),
+ dir: &repo_dir.join("testing").join("data").join("csv"),
+ ext: "csv",
+ },
+ )
+ .await?;
+ // register schemas into catalog
+ catalog.register_schema("parquet", parquet_schema.clone())?;
+ catalog.register_schema("csv", csv_schema.clone())?;
+ // register our catalog in the context
+ ctx.register_catalog("dircat", Arc::new(catalog));
+ {
+ // catalog was passed down into our custom catalog list since we overide the ctx's default
+ let catalogs = catlist.catalogs.read().unwrap();
+ assert!(catalogs.contains_key("dircat"));
+ };
+ let parquet_tables = {
+ let tables = parquet_schema.tables.read().unwrap();
+ tables.keys().take(5).cloned().collect::<Vec<_>>()
Review Comment:
Good point. 5 was totally arbitrary to be honest. Wanted to show a few tables in the output but not fill up the user's entire screen with table results. I'll add that as a comment.
--
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 #5326: Add example of catalog API usage (#5291)
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326#discussion_r1111056677
##########
datafusion-examples/examples/catalog.rs:
##########
@@ -0,0 +1,287 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Simple example of a catalog/schema implementation.
+//!
+//! Example requires git submodules to be initialized in repo as it uses data from
+//! the `parquet-testing` repo.
+use async_trait::async_trait;
+use datafusion::{
+ arrow::util::pretty,
+ catalog::{
+ catalog::{CatalogList, CatalogProvider},
+ schema::SchemaProvider,
+ },
+ datasource::{
+ file_format::{csv::CsvFormat, parquet::ParquetFormat, FileFormat},
+ listing::{ListingOptions, ListingTable, ListingTableConfig, ListingTableUrl},
+ TableProvider,
+ },
+ error::Result,
+ execution::context::SessionState,
+ prelude::SessionContext,
+};
+use std::sync::RwLock;
+use std::{
+ any::Any,
+ collections::HashMap,
+ path::{Path, PathBuf},
+ sync::Arc,
+};
+
+#[tokio::main]
+async fn main() -> Result<()> {
+ let repo_dir = std::fs::canonicalize(
+ PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+ // parent dir of datafusion-examples = repo root
+ .join(".."),
+ )
+ .unwrap();
+ let mut ctx = SessionContext::new();
+ let state = ctx.state();
+ let catlist = Arc::new(CustomCatalogList::new());
+ // use our custom catalog list for context. each context has a single catalog list.
+ // context will by default have MemoryCatalogList
+ ctx.register_catalog_list(catlist.clone());
+
+ // intitialize our catalog and schemas
+ let catalog = DirCatalog::new();
+ let parquet_schema = DirSchema::create(
+ &state,
+ DirSchemaOpts {
+ format: Arc::new(ParquetFormat::default()),
+ dir: &repo_dir.join("parquet-testing").join("data"),
+ ext: "parquet",
+ },
+ )
+ .await?;
+ let csv_schema = DirSchema::create(
+ &state,
+ DirSchemaOpts {
+ format: Arc::new(CsvFormat::default()),
+ dir: &repo_dir.join("testing").join("data").join("csv"),
+ ext: "csv",
+ },
+ )
+ .await?;
+ // register schemas into catalog
+ catalog.register_schema("parquet", parquet_schema.clone())?;
+ catalog.register_schema("csv", csv_schema.clone())?;
+ // register our catalog in the context
+ ctx.register_catalog("dircat", Arc::new(catalog));
+ {
+ // catalog was passed down into our custom catalog list since we overide the ctx's default
+ let catalogs = catlist.catalogs.read().unwrap();
+ assert!(catalogs.contains_key("dircat"));
+ };
+ let parquet_tables = {
+ let tables = parquet_schema.tables.read().unwrap();
+ tables.keys().take(5).cloned().collect::<Vec<_>>()
Review Comment:
I wonder if there is some reason to limit it to 5 files?
Maybe we could add a comment about the choice of that value
--
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 #5326: Add example of catalog API usage (#5291)
Posted by "ursabot (via GitHub)" <gi...@apache.org>.
ursabot commented on PR #5326:
URL: https://github.com/apache/arrow-datafusion/pull/5326#issuecomment-1445356302
Benchmark runs are scheduled for baseline = a7a824ad94f0726adf924f47b52de50ca36c4b09 and contender = 5ffa8d78f7e5796fa7c2f98b19346576ab2a4bb8. 5ffa8d78f7e5796fa7c2f98b19346576ab2a4bb8 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/f55ea72cd6eb46b2adb3b19669ac1360...acc5b411ae9c44c08eb090472f836736/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/4585bc47363248f594042c420b479cb3...35abde722e454ac2818c2fe3b0198116/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/eed6205a63b94b7baf7033f67f6853e2...1ac0b9c9dd304b4d8f742e88b719b0d1/)
[Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/b6940b172e4f474eb6a4e1fb29bc31fe...db87ab560fd549b3bb2ccd1b110ce22a/)
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