Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/commands/ddsql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,9 +784,7 @@ pub async fn table(
query: &str,
from: &str,
to: &str,
_interval: Option<i64>,
limit: Option<i32>,
_offset: Option<i32>,
) -> Result<()> {
let query = resolve_query(query)?;
let rows = execute_ddsql_query(cfg, &query, from, to, limit.map(i64::from)).await?;
Expand Down
24 changes: 15 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
nmuldavin marked this conversation as resolved.
/// 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)]
Expand Down Expand Up @@ -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<i64>,
#[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<i32>,
},
/// Print DDSQL reference guidance from the editor tooling
Spec,
Expand Down Expand Up @@ -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?;
Expand Down
34 changes: 34 additions & 0 deletions src/test_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}

Comment thread
nmuldavin marked this conversation as resolved.
#[test]
fn test_ddsql_table_query_requires_explicit_value() {
let result = crate::Cli::command().try_get_matches_from(["pup", "ddsql", "table", "--query"]);
Expand Down