diff --git a/src/commands/ddsql.rs b/src/commands/ddsql.rs index 7024d53c..f532bf5b 100644 --- a/src/commands/ddsql.rs +++ b/src/commands/ddsql.rs @@ -784,9 +784,7 @@ pub async fn table( query: &str, from: &str, to: &str, - _interval: Option, limit: Option, - _offset: Option, ) -> Result<()> { let query = resolve_query(query)?; let rows = execute_ddsql_query(cfg, &query, from, to, limit.map(i64::from)).await?; diff --git a/src/main.rs b/src/main.rs index 037ba186..023d654c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1143,6 +1143,15 @@ enum Commands { /// pup ddsql schema tables --query ec2 --limit 100 /// pup ddsql schema columns --table-id public.aws.ec2_instance /// + /// PAGINATION: + /// Write OFFSET n LIMIT m in SQL to paginate deterministic, ordered results. + /// Results will be capped at 5000 rows. Extend this up to 10000 with --limit; + /// paginate to retrieve more than 10000 rows. + /// + /// TIME WINDOW: + /// Set the query-wide time window with --from/--to. Override it per source with + /// table-function timestamp arguments. A WHERE time filter does not change the source window. + /// /// AUTHENTICATION: /// All ddsql commands support OAuth2 (via 'pup auth login') or API key + Application key. #[command(verbatim_doc_comment)] @@ -4526,12 +4535,12 @@ enum DdsqlActions { help = "End time. Accepts the same formats as --from (e.g., now)" )] to: String, - #[arg(long, help = "Aggregation interval in milliseconds (default: 60000)")] - interval: Option, - #[arg(long, default_value_t = 50, help = "Maximum number of rows to return")] + #[arg( + long, + default_value_t = 5000, + help = "API response row cap (1-10000); use SQL LIMIT to bound query results" + )] limit: i32, - #[arg(long, help = "Number of rows to skip (for pagination)")] - offset: Option, }, /// Print DDSQL reference guidance from the editor tooling Spec, @@ -17059,12 +17068,9 @@ async fn main_inner() -> anyhow::Result<()> { query, from, to, - interval, limit, - offset, } => { - commands::ddsql::table(&cfg, &query, &from, &to, interval, Some(limit), offset) - .await?; + commands::ddsql::table(&cfg, &query, &from, &to, Some(limit)).await?; } DdsqlActions::Spec => { commands::ddsql::spec(&cfg).await?; diff --git a/src/test_commands.rs b/src/test_commands.rs index 6d874011..70ce8fb6 100644 --- a/src/test_commands.rs +++ b/src/test_commands.rs @@ -556,6 +556,40 @@ fn test_ddsql_table_query_accepts_explicit_stdin_marker() { } } +#[test] +fn test_ddsql_table_uses_api_row_limit_default() { + use clap::Parser; + + let cli = crate::Cli::try_parse_from(["pup", "ddsql", "table", "--query", "SELECT 1"]) + .expect("ddsql table should parse"); + + match cli.command { + crate::Commands::Ddsql { action } => match action { + crate::DdsqlActions::Table { limit, .. } => assert_eq!(limit, 5000), + _ => panic!("expected DdsqlActions::Table"), + }, + _ => panic!("expected Commands::Ddsql"), + } +} + +#[test] +fn test_ddsql_table_accepts_limit_override() { + use clap::Parser; + + let cli = crate::Cli::try_parse_from([ + "pup", "ddsql", "table", "--query", "SELECT 1", "--limit", "10000", + ]) + .expect("ddsql table should accept a row limit override"); + + match cli.command { + crate::Commands::Ddsql { action } => match action { + crate::DdsqlActions::Table { limit, .. } => assert_eq!(limit, 10000), + _ => panic!("expected DdsqlActions::Table"), + }, + _ => panic!("expected Commands::Ddsql"), + } +} + #[test] fn test_ddsql_table_query_requires_explicit_value() { let result = crate::Cli::command().try_get_matches_from(["pup", "ddsql", "table", "--query"]);