MCPcopy Create free account
hub / github.com/apache/datafusion / gcs_object_store_builder

Function gcs_object_store_builder

datafusion-cli/src/object_storage.rs:856–888  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

854
855 #[tokio::test]
856 async fn gcs_object_store_builder() -> Result<()> {
857 let service_account_path = "fake_service_account_path";
858 let service_account_key = "{\"private_key\": \"fake_private_key.pem\",\"client_email\":\"fake_client_email\"}";
859 let application_credentials_path = "fake_application_credentials_path";
860 let location = "gcs://bucket/path/file.parquet";
861
862 let table_url = ListingTableUrl::parse(location)?;
863 let scheme = table_url.scheme();
864 let sql = format!(
865 "CREATE EXTERNAL TABLE test STORED AS PARQUET OPTIONS('gcp.service_account_path' '{service_account_path}', 'gcp.service_account_key' '{service_account_key}', 'gcp.application_credentials_path' '{application_credentials_path}') LOCATION '{location}'"
866 );
867
868 let ctx = SessionContext::new();
869 ctx.register_table_options_extension_from_scheme(scheme);
870 let table_options = get_table_options(&ctx, &sql).await;
871
872 let gcp_options = table_options.extensions.get::<GcpOptions>().unwrap();
873 let builder = get_gcs_object_store_builder(table_url.as_ref(), gcp_options)?;
874 // get the actual configuration information, then assert_eq!
875 let config = [
876 (GoogleConfigKey::ServiceAccount, service_account_path),
877 (GoogleConfigKey::ServiceAccountKey, service_account_key),
878 (
879 GoogleConfigKey::ApplicationCredentials,
880 application_credentials_path,
881 ),
882 ];
883 for (key, value) in config {
884 assert_eq!(value, builder.get_config_value(&key).unwrap());
885 }
886
887 Ok(())
888 }
889
890 /// Plans the `CREATE EXTERNAL TABLE` SQL statement and returns the
891 /// resulting resolved `CreateExternalTable` command.

Callers

nothing calls this directly

Calls 6

newFunction · 0.85
get_table_optionsFunction · 0.85
schemeMethod · 0.80
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…