use serde_json::json;
use crate::adapters::bigquery::_helpers::dialect::pull::{group_table, table_definition};
use crate::adapters::bigquery::models::BigQueryDestination;
use crate::bigquery_api::main::query_schema::query_schema;
use crate::http::errors::ApiError;
pub(in crate::adapters) async fn check_files(
destination: &BigQueryDestination,
url: &str,
) -> Result<(), ApiError> {
let table = group_table(0);
let definitions = json!({ table.clone(): table_definition(&[url]) });
query_schema(
&destination.api,
&format!("SELECT * FROM {table}"),
Some(&definitions),
)
.await
.map(|_| ())
}