diff --git a/changelog.d/767.compat.md b/changelog.d/767.compat.md new file mode 100644 index 000000000..58da65f7a --- /dev/null +++ b/changelog.d/767.compat.md @@ -0,0 +1 @@ +`filter` takes the element index (`(x, i) -> ...`), `reverse` works on arrays, `sequence` works over dates and timestamps with year-month, day-time and calendar steps, `to_char` and `to_varchar` accept binary values (`hex`, `base64`, `utf-8`), and `schema_of_xml` honours `excludeAttribute`, `ignoreNamespace` and `prefersDecimal` and merges repeated elements the way Spark does (SQL-4, SQL-5, SQL-6). diff --git a/crates/krishiv-exec/src/planner/eval/hof.rs b/crates/krishiv-exec/src/planner/eval/hof.rs index 8f0d4ed12..61b4d8d44 100644 --- a/crates/krishiv-exec/src/planner/eval/hof.rs +++ b/crates/krishiv-exec/src/planner/eval/hof.rs @@ -14,7 +14,7 @@ //! //! For a batch of `rows` rows whose lists hold `total` elements, the //! flattened batch has `total` rows: the lambda's element columns are the -//! lists' child values, its index column (two-variable `transform`) counts +//! lists' child values, its index column (two-variable `transform` or `filter`) counts //! positions within each list, and every captured outer column repeats its //! row's value per element (through the lists' offsets). A vectorized body //! runs once over that batch — never one evaluation per element — and the @@ -454,7 +454,7 @@ fn compile_unary(name: &str, f: &ResolvedFunction, input: Input<'_>) -> Result) -> Option { }) } +/// The result element type of `sequence(start, stop[, step])` over temporal bounds (Spark 4.2.0): `DATE` for two dates, else a timestamp +/// (`TIMESTAMP_NTZ` only when no bound is a plain `TIMESTAMP`; a `DATE` beside either takes its type). `None` unless some bound is +/// temporal and none is anything else. +fn temporal_sequence_type(c: &CallTypes<'_>) -> Option { + if c.args().len() < 2 { + return None; + } + let is_time = |t: &DataType| { + matches!( + t, + DataType::Date | DataType::Timestamp | DataType::TimestampNtz + ) + }; + let bounds: Vec> = (0..2).map(|i| c.data_type(i)).collect(); + // An untyped NULL bound, or (under ANSI) a string, is cast to the other bound's type; at least one bound is a date or timestamp. + let castable = |t: &Option<&DataType>| match t { + None => true, + Some(DataType::String) => c.ansi(), + Some(t) => is_time(t), + }; + if !bounds.iter().any(|t| t.is_some_and(is_time)) || !bounds.iter().all(castable) { + return None; + } + let has = |want: &DataType| bounds.contains(&Some(want)); + Some(if has(&DataType::Timestamp) { + DataType::Timestamp + } else if has(&DataType::TimestampNtz) { + DataType::TimestampNtz + } else { + DataType::Date + }) +} + /// `sequence`'s inputs: every argument is cast to the widest integral type. fn sequence_inputs(c: &CallTypes<'_>) -> Vec { + if let Some(t) = temporal_sequence_type(c) { + // The bounds are cast to the common temporal type; the step keeps its own (checked in the result rule). + let mut v = vec![InputType::Exact(t.clone()), InputType::Exact(t)]; + if c.args().len() > 2 { + v.push(InputType::Any); + } + return v; + } match sequence_type(c) { Some(t) => vec![InputType::Exact(t); c.args().len()], None => vec![InputType::Any; c.args().len()], @@ -155,17 +196,34 @@ fn sequence(c: &CallTypes<'_>) -> Result { c.any_nullable(), )); } - let temporal = |t: Option<&DataType>| { - matches!( - t, - Some(DataType::Date | DataType::Timestamp | DataType::TimestampNtz) - ) - }; - if temporal(c.data_type(0)) || temporal(c.data_type(1)) { - return Err(KrishivUnsupportedFeature { - feature: "sequence over dates or timestamps".to_owned(), + if let Some(t) = temporal_sequence_type(c) { + // The step is a calendar, year-month or day-time interval; anything else (an integral, a string, an untyped NULL) is a type error. + let interval = |i: usize| { + matches!( + c.data_type(i), + Some( + DataType::CalendarInterval + | DataType::YearMonthInterval { .. } + | DataType::DayTimeInterval { .. } + ) + ) + }; + if n == 3 && !interval(2) { + return Err(DatatypeMismatchSequenceWrongInputTypes { + sql_expr: call_sql("sequence", c), + function_name: "`sequence`".to_owned(), + start_type: "(\"TIMESTAMP\" or \"TIMESTAMP_NTZ\" or \"DATE\")".to_owned(), + step_type: + "(\"INTERVAL\" or \"INTERVAL YEAR TO MONTH\" or \"INTERVAL DAY TO SECOND\")" + .to_owned(), + other_start_type: "\"INTEGRAL\"".to_owned(), + } + .into()); } - .into()); + return Ok(ArgType::new( + DataType::Array(ArrayType::new(t, false).into()), + c.any_nullable(), + )); } Err(DatatypeMismatchSequenceWrongInputTypes { sql_expr: call_sql("sequence", c), diff --git a/crates/krishiv-functions/src/registry/number.rs b/crates/krishiv-functions/src/registry/number.rs index d79ad5ed6..40c824a94 100644 --- a/crates/krishiv-functions/src/registry/number.rs +++ b/crates/krishiv-functions/src/registry/number.rs @@ -20,7 +20,7 @@ use std::sync::Arc; use krishiv_common::error::{ DatatypeMismatchNonFoldableInput, DatatypeMismatchUnexpectedInputType, - InvalidParameterValueBinaryFormat, KrishivError, + InvalidParameterValueBinaryFormat, InvalidParameterValueNull, KrishivError, }; use krishiv_kernels::cast::{CastMode, CastOptions, TimeZoneRules, cast}; use krishiv_kernels::number_format::parse_format; @@ -508,6 +508,14 @@ fn to_char_result(c: &CallTypes<'_>) -> Result { // Binaries take `base64`/`hex`/`utf-8` (matched lower-cased, like // Spark's `toLowerCase.trim`). if matches!(c.data_type(0), Some(DataType::Binary)) { + // Spark's `ToCharacterBuilder` refuses a NULL format for a binary. + if matches!(c.constant(1), Some(Constant::Null)) { + return Err(InvalidParameterValueNull { + parameter: "`format`".to_owned(), + function_name: "`to_char`".to_owned(), + } + .into()); + } if let Some(pattern) = format.as_deref() && !matches!( pattern.to_lowercase().trim_matches(|c: char| c <= ' '), diff --git a/crates/krishiv-functions/src/registry/tests/text.rs b/crates/krishiv-functions/src/registry/tests/text.rs index 096a06a37..921fbf703 100644 --- a/crates/krishiv-functions/src/registry/tests/text.rs +++ b/crates/krishiv-functions/src/registry/tests/text.rs @@ -268,3 +268,16 @@ fn argument_casts_follow_spark() { InputType::Any ); } + +#[test] +fn to_char_of_a_binary_refuses_a_null_format() { + let args = [ty(DataType::Binary), ty(DataType::String)]; + for name in ["to_char", "to_varchar"] { + let err = result(name, &args, &[None, Some(Constant::Null)]).unwrap_err(); + assert_eq!( + err.error_class(), + ErrorClass::InvalidParameterValueNull, + "{name}" + ); + } +} diff --git a/crates/krishiv-functions/src/registry/text.rs b/crates/krishiv-functions/src/registry/text.rs index 0dfecec11..668896986 100644 --- a/crates/krishiv-functions/src/registry/text.rs +++ b/crates/krishiv-functions/src/registry/text.rs @@ -226,9 +226,16 @@ pub(super) fn specs() -> Vec { &Inputs::Expects(vec![InputType::Strict(DataType::String)]), string, )); + // `reverse` takes a string, a binary or an array (Spark's `TypeCollection(StringType, ArrayType)`): an array keeps its type. out.extend(scalar( &["reverse"], - &Inputs::Expects(vec![text_or_bytes.clone()]), + &Inputs::Built(InputBuilder(|c: &CallTypes<'_>| { + if matches!(c.data_type(0), Some(DataType::Array(_))) { + vec![InputType::Array] + } else { + vec![InputType::OneOf(vec![DataType::String, DataType::Binary])] + } + })), first_type, )); out.extend(scalar(&["quote"], &one_text, nullable_string)); diff --git a/crates/krishiv-functions/src/scalar/array_shape.rs b/crates/krishiv-functions/src/scalar/array_shape.rs index 3e6913681..5e1da1adc 100644 --- a/crates/krishiv-functions/src/scalar/array_shape.rs +++ b/crates/krishiv-functions/src/scalar/array_shape.rs @@ -15,7 +15,7 @@ use arrow_array::{Array, ArrayRef, Int32Array, StringArray}; use arrow_schema::{DataType, Field}; use krishiv_common::error::{ CollectionSizeLimitExceededParameter, InvalidParameterValueLength, InvalidParameterValueStart, - KrishivError, LegacyErrorTemp3243, + KrishivError, LegacyErrorTemp3242, LegacyErrorTemp3243, }; use super::args::{Inputs, internal, to_utf8}; @@ -26,7 +26,7 @@ use super::{BindArg, BindOptions, Binding, FamilyResult, bad_types, listed}; pub(super) const NAMES: &[&str] = &["array_join", "flatten", "sequence", "slice"]; /// Binds the function `name` to `args`. -pub(super) fn bind(name: &str, args: &[BindArg], _opts: &BindOptions) -> FamilyResult { +pub(super) fn bind(name: &str, args: &[BindArg], opts: &BindOptions) -> FamilyResult { let listed = listed(NAMES, name)?; let types: Vec = args.iter().map(BindArg::data_type).collect(); let binding = match (listed, types.as_slice()) { @@ -59,6 +59,11 @@ pub(super) fn bind(name: &str, args: &[BindArg], _opts: &BindOptions) -> FamilyR sequence(x, &element, &field, steps) })) } + ("sequence", [first, second, rest @ ..]) + if temporal_bound(first) && first == second && rest.len() <= 1 => + { + temporal_binding(first, rest.first(), opts) + } ("slice", [t @ DataType::List(f), DataType::Int32, DataType::Int32]) => { let field = Arc::clone(f); Ok(Binding::new(t.clone(), move |x: &Inputs<'_>| { @@ -148,6 +153,15 @@ fn longs(x: &Inputs<'_>, i: usize) -> Result>, KrishivError> { .map(|v| v.map(i64::from)) .collect(), DataType::Int64 => c.as_primitive::().iter().collect(), + DataType::Date32 => c + .as_primitive::() + .iter() + .map(|v| v.map(i64::from)) + .collect(), + DataType::Timestamp(arrow_schema::TimeUnit::Microsecond, _) => c + .as_primitive::() + .iter() + .collect(), t => return Err(internal(format!("sequence over {t}"))), }) } @@ -253,6 +267,37 @@ fn sequence( Ok(Arc::new(list)) } +/// `reverse(array)`: the elements in the opposite order, NULL elements kept in place, NULL for a NULL array (the string and +/// binary forms are in `chars`). +pub(super) fn reverse_binding(t: &DataType) -> Option { + let DataType::List(f) = t else { + return None; + }; + let field = Arc::clone(f); + Some(Binding::new(t.clone(), move |x: &Inputs<'_>| { + reverse(x, &field) + })) +} + +fn reverse(x: &Inputs<'_>, field: &Arc) -> Result { + let c = x.column(0)?; + let list = list_of(&c, "reverse")?; + let mut rows = Vec::with_capacity(x.rows()); + for row in 0..x.rows() { + if list.is_null(row) { + rows.push(None); + continue; + } + let (first, size) = span(list, row); + let mut picks = Vec::with_capacity(size); + for at in (first..first + size).rev() { + picks.push(Some(index(at)?)); + } + rows.push(Some(picks)); + } + rebuild(field, list.values(), &rows, "reverse", MAX_ARRAY_LENGTH) +} + /// `slice(arr, start, length)`. fn slice(x: &Inputs<'_>, field: &Arc) -> Result { let c = x.column(0)?; @@ -351,3 +396,289 @@ fn join(x: &Inputs<'_>, replaced: bool) -> Result { } Ok(Arc::new(StringArray::from(out))) } + +/// Whether `t` is a bound `sequence` takes over time: a date or a (zoned or zone-less) microsecond timestamp. +fn temporal_bound(t: &DataType) -> bool { + matches!( + t, + DataType::Date32 | DataType::Timestamp(arrow_schema::TimeUnit::Microsecond, _) + ) +} + +/// How a step is read: its `(months, days, micros)` per row. +#[derive(Clone, Copy)] +enum StepKind { + YearMonth, + DayTime, + Calendar, +} + +fn temporal_binding( + bound: &DataType, + step: Option<&DataType>, + opts: &BindOptions, +) -> Result { + use arrow_schema::{IntervalUnit, TimeUnit}; + let kind = match step { + None => None, + Some(DataType::Interval(IntervalUnit::YearMonth)) => Some(StepKind::YearMonth), + Some(DataType::Duration(TimeUnit::Microsecond)) => Some(StepKind::DayTime), + Some(t) if krishiv_types::arrow::is_calendar_struct(t) => Some(StepKind::Calendar), + Some(_) => { + return Err(internal( + "a sequence step that is not an interval".to_owned(), + )); + } + }; + let element = bound.clone(); + let field = Arc::new(Field::new("item", element.clone(), false)); + let zone = Arc::clone(&opts.time_zone); + Ok(Binding::new( + DataType::List(Arc::clone(&field)), + move |x: &Inputs<'_>| temporal_sequence(x, &element, &field, kind, zone.as_ref()), + )) +} + +/// A step as `(months, days, micros)`. +type Step = (i64, i64, i64); + +/// Every row's step as `(months, days, micros)` (`None` for a NULL step): a year-month interval is months; a day-time one splits into +/// whole days and the remainder; a calendar interval is its three fields. Read once per batch. +fn read_steps(x: &Inputs<'_>, kind: StepKind) -> Result>, KrishivError> { + use arrow_array::types::{DurationMicrosecondType, IntervalYearMonthType}; + let col = x.column(2)?; + Ok(match kind { + StepKind::YearMonth => col + .as_primitive::() + .iter() + .map(|v| v.map(|m| (i64::from(m), 0, 0))) + .collect(), + StepKind::DayTime => col + .as_primitive::() + .iter() + .map(|v| v.map(|m| (0, m / MICROS_PER_DAY, m % MICROS_PER_DAY))) + .collect(), + StepKind::Calendar => { + let c = krishiv_types::calendar::Calendars::of(col.as_ref()).ok_or_else(|| { + internal("a sequence step that is not a calendar interval".to_owned()) + })?; + c.iter() + .map(|v| v.map(|v| (i64::from(v.months), i64::from(v.days), v.micros))) + .collect() + } + }) +} + +const MICROS_PER_DAY: i64 = 86_400_000_000; + +/// `sequence(start, stop[, step])` over dates or timestamps (Spark 4.2.0, goldens `functions/sequence_xml`): element `i` is `start` +/// plus `i * step` (months, then calendar days on the local clock, then elapsed microseconds), taken from the start each time, +/// while it has not passed `stop`; a missing step is one day towards `stop`. +fn temporal_sequence( + x: &Inputs<'_>, + element: &DataType, + field: &Arc, + kind: Option, + zone: &dyn krishiv_kernels::datetime::TimeZoneRules, +) -> Result { + use krishiv_kernels::datetime::{ + add_day_time_to_timestamp, add_months_to_date, add_months_to_timestamp, + }; + let is_date = matches!(element, DataType::Date32); + let tz: Option<&dyn krishiv_kernels::datetime::TimeZoneRules> = match element { + DataType::Timestamp(_, Some(_)) => Some(zone), + _ => None, + }; + let (starts, stops) = (longs(x, 0)?, longs(x, 1)?); + let steps = kind.map(|k| read_steps(x, k)).transpose()?; + let mut offsets: Vec = vec![0]; + let mut valid = Vec::with_capacity(x.rows()); + let mut values: Vec = Vec::new(); + for row in 0..x.rows() { + let step = match &steps { + Some(all) => all[row], + None => Some((0, 0, 0)), + }; + let (Some(start), Some(stop), Some(step)) = (starts[row], stops[row], step) else { + valid.push(false); + offsets.push(offsets[row]); + continue; + }; + let (mut months, mut days, micros) = step; + if kind.is_none() { + days = if start <= stop { 1 } else { -1 }; + months = 0; + } + let type_name = match kind { + Some(StepKind::YearMonth) => "year to month", + Some(StepKind::DayTime) => "day to second", + _ => "interval", + }; + if is_date && months == 0 && days == 0 { + return Err(LegacyErrorTemp3242 { + interval_type: format!("interval {type_name}") + .replace("interval interval", "interval"), + } + .into()); + } + // The direction is the one from start to stop; the step must move that way. Spark's estimate of the step is + // `months * 28 days + days + micros`, and equal bounds give one element for any step a timestamp takes. + let rest = i128::from(days) * i128::from(MICROS_PER_DAY) + i128::from(micros); + let sign = (i128::from(months) * 28 * i128::from(MICROS_PER_DAY) + rest).signum(); + let up = start <= stop; + // A step whose days and microseconds cancel out (`1 day` and `-24 hours`) never advances: it is a zero step. + let advances = + months != 0 || i128::from(days) * i128::from(MICROS_PER_DAY) + i128::from(micros) != 0; + if !advances && start != stop { + return Err(LegacyErrorTemp3243 { + start: start.to_string(), + stop: stop.to_string(), + step: "0".to_owned(), + } + .into()); + } + if !(start == stop || (up && sign > 0) || (!up && sign < 0)) { + return Err(LegacyErrorTemp3243 { + start: start.to_string(), + stop: stop.to_string(), + step: if months != 0 && days == 0 && micros == 0 { + months.to_string() + } else { + (i128::from(days) * i128::from(MICROS_PER_DAY) + i128::from(micros)).to_string() + }, + } + .into()); + } + // A step of days and microseconds only has its length up front, so a huge result fails before any element is built + // (`1 microsecond` over a year is `numberOfElements` 31449600000001); a month step cannot reach the limit. + if months == 0 { + let step = i128::from(days) * i128::from(MICROS_PER_DAY) + i128::from(micros); + let unit = if is_date { + i128::from(MICROS_PER_DAY) + } else { + 1 + }; + let span = (i128::from(stop) - i128::from(start)) * unit; + let count = if step == 0 { 1 } else { span / step + 1 }; + if count > i128::try_from(MAX_ARRAY_LENGTH).unwrap_or(i128::MAX) { + return Err(CollectionSizeLimitExceededParameter { + function_name: "`sequence`".to_owned(), + parameter: "`count`".to_owned(), + number_of_elements: count.to_string(), + max_rounded_array_length: MAX_ARRAY_LENGTH.to_string(), + } + .into()); + } + } + // Whole-day steps over dates have their length from the micros (`(stop - start) / step + 1`), as Spark computes it before + // taking the elements: `1 day 12 hours` from Jan 1 to Jan 5 gives Jan 1, Jan 2, Jan 4. + let date_count = (is_date && months == 0).then(|| { + let step = i128::from(days) * i128::from(MICROS_PER_DAY) + i128::from(micros); + let span = (i128::from(stop) - i128::from(start)) * i128::from(MICROS_PER_DAY); + if step == 0 { 1 } else { span / step + 1 } + }); + let first = values.len(); + let overflow = |what: &str| internal(format!("sequence {what} out of range")); + let mut i: i64 = 0; + loop { + let at = if is_date { + let moved = add_months_to_date( + i32::try_from(start).map_err(|_| overflow("date"))?, + months.checked_mul(i).ok_or_else(|| overflow("months"))?, + ) + .ok_or_else(|| overflow("date"))?; + // A date's step is whole days: the remainder of `i * micros` below a day is dropped (`1 day 12 hours` gives + // Jan 1, Jan 2, Jan 4). + let extra = micros + .checked_mul(i) + .ok_or_else(|| overflow("micros"))? + .div_euclid(MICROS_PER_DAY); + i64::from(moved) + .checked_add(days.checked_mul(i).ok_or_else(|| overflow("days"))?) + .and_then(|d| d.checked_add(extra)) + .ok_or_else(|| overflow("date"))? + } else { + let by_months = add_months_to_timestamp( + start, + months.checked_mul(i).ok_or_else(|| overflow("months"))?, + tz, + ) + .ok_or_else(|| overflow("timestamp"))?; + let by_days = add_day_time_to_timestamp( + by_months, + days.checked_mul(i) + .and_then(|d| d.checked_mul(MICROS_PER_DAY)) + .ok_or_else(|| overflow("days"))?, + tz, + ) + .ok_or_else(|| overflow("timestamp"))?; + by_days + .checked_add(micros.checked_mul(i).ok_or_else(|| overflow("micros"))?) + .ok_or_else(|| overflow("timestamp"))? + }; + // A date element that falls on `stop` with a time of day left over (`1 month 1 hour`) is after `stop`. + let sub_day = if is_date { + micros.wrapping_mul(i).rem_euclid(MICROS_PER_DAY) + } else { + 0 + }; + let past = if up { + at > stop || (at == stop && sub_day > 0 && i > 0) + } else { + at < stop + }; + if past || date_count.is_some_and(|n| i128::from(i) >= n) { + break; + } + if start == stop && i > 0 { + break; + } + // A month step whose other fields pull the other way can wander without reaching `stop`: bound the steps taken. + // Steps without months are bounded by the up-front length check and `MAX_ARRAY_LENGTH` instead. + if months != 0 && i > 12_000_000 { + return Err(LegacyErrorTemp3243 { + start: start.to_string(), + stop: stop.to_string(), + step: months.to_string(), + } + .into()); + } + values.push(at); + if values.len() - first > MAX_ARRAY_LENGTH { + return Err(CollectionSizeLimitExceededParameter { + function_name: "`sequence`".to_owned(), + parameter: "`count`".to_owned(), + number_of_elements: (values.len() - first).to_string(), + max_rounded_array_length: MAX_ARRAY_LENGTH.to_string(), + } + .into()); + } + i += 1; + } + valid.push(true); + offsets.push(i32::try_from(values.len()).map_err(|_| too_long("sequence", values.len()))?); + } + let child: ArrayRef = match element { + DataType::Date32 => Arc::new(arrow_array::Date32Array::from( + values + .iter() + .map(|v| { + i32::try_from(*v) + .map_err(|_| internal("a sequence date out of range".to_owned())) + }) + .collect::, _>>()?, + )), + DataType::Timestamp(_, tzname) => Arc::new( + arrow_array::TimestampMicrosecondArray::from(values).with_timezone_opt(tzname.clone()), + ), + other => return Err(internal(format!("a sequence over {other}"))), + }; + let list = arrow_array::ListArray::try_new( + Arc::clone(field), + arrow_buffer::OffsetBuffer::new(offsets.into()), + child, + Some(arrow_buffer::NullBuffer::from(valid)), + ) + .map_err(|e| internal(e.to_string()))?; + Ok(Arc::new(list)) +} diff --git a/crates/krishiv-functions/src/scalar/chars.rs b/crates/krishiv-functions/src/scalar/chars.rs index 809235417..1f1bc147a 100644 --- a/crates/krishiv-functions/src/scalar/chars.rs +++ b/crates/krishiv-functions/src/scalar/chars.rs @@ -59,6 +59,13 @@ pub(super) const NAMES: &[&str] = &[ /// Binds the character function `name`. pub(super) fn bind(name: &str, args: &[BindArg], opts: &BindOptions) -> FamilyResult { let listed = listed(NAMES, name)?; + if listed == "reverse" + && let Some(binding) = args + .first() + .and_then(|a| super::array_shape::reverse_binding(&a.data_type())) + { + return Some((listed, Ok(binding))); + } let shape = shape(args); let ansi = opts.ansi; let ctx = opts.kernel; diff --git a/crates/krishiv-functions/src/scalar/number.rs b/crates/krishiv-functions/src/scalar/number.rs index a339d3738..1697ecf72 100644 --- a/crates/krishiv-functions/src/scalar/number.rs +++ b/crates/krishiv-functions/src/scalar/number.rs @@ -386,6 +386,36 @@ fn to_number(name: &'static str, args: &[BindArg], try_: bool) -> Result Result { + let format = literal_format(&args[1])?; + let Some(format) = format else { + // A NULL format: every row is NULL. + return Ok(Binding::new(DataType::Utf8, |x: &Inputs<'_>| { + Ok(string_array(&vec![None; x.rows()])) + })); + }; + match format.to_lowercase().trim_matches(|c: char| c <= ' ') { + "hex" => hex(&args[0].data_type()).ok_or_else(|| bad_types("to_char", args)), + "base64" => Ok(Binding::new(DataType::Utf8, |x: &Inputs<'_>| { + Ok(Arc::new(krishiv_kernels::string::base64(&x.binaries(0)?, true)?) as ArrayRef) + })), + "utf-8" => Ok(Binding::new(DataType::Utf8, move |x: &Inputs<'_>| { + let charset = krishiv_kernels::string::StrOperand::::Scalar(Some("utf-8")); + Ok(Arc::new(krishiv_kernels::string::decode_with( + x.bin(0)?.operand(), + charset, + charsets, + )?) as ArrayRef) + })), + _ => Err(bad_types("to_char", args)), + } +} + /// `to_char(x, format)` / `to_varchar`: a decimal by an Oracle pattern (a /// mismatch raises `INVALID_FORMAT.MISMATCH_INPUT`). fn to_char(args: &[BindArg]) -> Result { @@ -458,6 +488,9 @@ pub(super) fn bind(name: &str, args: &[BindArg], opts: &BindOptions) -> FamilyRe ("to_number", [n, f]) if is_string(n) && is_string(f) => to_number(listed, args, false), ("try_to_number", [n, f]) if is_string(n) && is_string(f) => to_number(listed, args, true), ("to_char" | "to_varchar", [DataType::Decimal128(..), f]) if is_string(f) => to_char(args), + ("to_char" | "to_varchar", [b, f]) if is_binary(b) && is_string(f) => { + to_char_binary(args, opts.charsets) + } _ => return Some((listed, Err(bad_types(listed, args)))), }; Some((listed, binding)) diff --git a/crates/krishiv-functions/src/scalar/tests/array_shape.rs b/crates/krishiv-functions/src/scalar/tests/array_shape.rs index 3e7d89dd4..c40e21287 100644 --- a/crates/krishiv-functions/src/scalar/tests/array_shape.rs +++ b/crates/krishiv-functions/src/scalar/tests/array_shape.rs @@ -62,3 +62,109 @@ fn unsupported_shapes_do_not_bind() { .is_err() ); } + +#[test] +fn reverse_of_an_array_reverses_the_elements_and_keeps_nulls_and_empty_arrays() { + use arrow_array::builder::{Int32Builder, ListBuilder}; + let mut b = ListBuilder::new(Int32Builder::new()); + for row in [ + Some(vec![Some(2), Some(1), Some(4), Some(3)]), + Some(vec![Some(1), None, Some(3)]), + Some(vec![]), + None, + ] { + match row { + Some(v) => { + for x in v { + b.values().append_option(x); + } + b.append(true); + } + None => b.append(false), + } + } + let list: ArrayRef = Arc::new(b.finish()); + let f = bind_with("reverse", &[&list], &BindOptions::new()); + assert_eq!(f.return_type(), list.data_type()); + let out = f.invoke(&[col(&list)], 4).unwrap(); + let out = out.as_list::(); + let ints = |row: usize| -> Vec> { + out.value(row) + .as_primitive::() + .iter() + .collect() + }; + assert_eq!(ints(0), [Some(3), Some(4), Some(1), Some(2)]); + assert_eq!(ints(1), [Some(3), None, Some(1)]); + assert!(ints(2).is_empty()); + assert!(out.is_null(3)); +} + +#[test] +fn sequence_over_dates_needs_a_whole_day_step_and_a_step_that_advances() { + use arrow_array::types::DurationMicrosecondType; + use arrow_array::{Date32Array, PrimitiveArray}; + use krishiv_common::error::ErrorClass; + let start: ArrayRef = Arc::new(Date32Array::from(vec![17532])); + let stop: ArrayRef = Arc::new(Date32Array::from(vec![17536])); + let step = |micros: i64| -> ArrayRef { + Arc::new(PrimitiveArray::::from(vec![ + micros, + ])) + }; + let run = |micros: i64| { + let s = step(micros); + let f = bind_with("sequence", &[&start, &stop, &s], &BindOptions::new()); + f.invoke(&[col(&start), col(&stop), col(&s)], 1) + }; + // `sequence step must be an interval day to second of day granularity if start and end values are dates` (Spark: `_LEGACY_ERROR_TEMP_3242`). + assert_eq!( + run(12 * 3_600_000_000).unwrap_err().error_class(), + ErrorClass::LegacyErrorTemp3242 + ); + assert_eq!( + run(0).unwrap_err().error_class(), + ErrorClass::LegacyErrorTemp3242 + ); + // A step of one day over four days gives five dates. + let out = run(86_400_000_000).unwrap(); + assert_eq!(out.as_list::().value(0).len(), 5); + // A step that moves backwards cannot reach a later stop (Spark: `_LEGACY_ERROR_TEMP_3243`). + assert_eq!( + run(-86_400_000_000).unwrap_err().error_class(), + ErrorClass::LegacyErrorTemp3243 + ); +} + +#[test] +fn a_long_sequence_without_months_is_not_cut_off_by_the_calendar_guard() { + use arrow_array::types::DurationMicrosecondType; + use arrow_array::{PrimitiveArray, TimestampMicrosecondArray}; + // 12,000,002 elements of one microsecond each: far below the array limit. + let start: ArrayRef = Arc::new(TimestampMicrosecondArray::from(vec![0_i64])); + let stop: ArrayRef = Arc::new(TimestampMicrosecondArray::from(vec![12_000_001_i64])); + let step: ArrayRef = Arc::new(PrimitiveArray::::from(vec![1_i64])); + let f = bind_with("sequence", &[&start, &stop, &step], &BindOptions::new()); + let out = f.invoke(&[col(&start), col(&stop), col(&step)], 1).unwrap(); + assert_eq!(out.as_list::().value(0).len(), 12_000_002); +} + +#[test] +fn a_descending_date_sequence_floors_the_part_of_a_day() { + use arrow_array::types::DurationMicrosecondType; + use arrow_array::{Date32Array, PrimitiveArray}; + // 2018-01-05 down to 2018-01-01 by 36 hours: Spark converts each instant to a date, so the elements are Jan 5, 3 and 2. + let start: ArrayRef = Arc::new(Date32Array::from(vec![17536])); + let stop: ArrayRef = Arc::new(Date32Array::from(vec![17532])); + let step: ArrayRef = Arc::new(PrimitiveArray::::from(vec![ + -36 * 3_600_000_000_i64, + ])); + let f = bind_with("sequence", &[&start, &stop, &step], &BindOptions::new()); + let out = f.invoke(&[col(&start), col(&stop), col(&step)], 1).unwrap(); + let list = out.as_list::().value(0); + let got: Vec = list + .as_primitive::() + .values() + .to_vec(); + assert_eq!(got, vec![17536, 17534, 17533]); +} diff --git a/crates/krishiv-functions/src/scalar/tests/number.rs b/crates/krishiv-functions/src/scalar/tests/number.rs index eb8c11ed5..c47dce725 100644 --- a/crates/krishiv-functions/src/scalar/tests/number.rs +++ b/crates/krishiv-functions/src/scalar/tests/number.rs @@ -502,3 +502,48 @@ fn format_number_int_values_and_null_formats() { super::owned(&[None]) ); } + +/// SQL-6: `to_char` and `to_varchar` over a binary (Spark 4.2.0: `hex` upper case, `base64`, `utf-8`). +#[test] +fn to_char_of_a_binary_by_hex_base64_and_utf8() { + use arrow_array::BinaryArray; + let data: ArrayRef = Arc::new(BinaryArray::from(vec![ + Some(&b"Spark SQL"[..]), + Some(&b"abc"[..]), + None, + ])); + let run = |name: &str, format: &str| -> Vec> { + let fmt: ArrayRef = Arc::new(StringArray::from(vec![Some(format)])); + let f = bind_scalar( + name, + &[ + BindArg::Column { + ty: data.data_type().clone(), + nullable: true, + }, + BindArg::Literal(Arc::clone(&fmt)), + ], + &BindOptions::new(), + ) + .unwrap(); + let out = f.invoke(&[col(&data), lit(&fmt)], 3).unwrap(); + out.as_string::() + .iter() + .map(|s| s.map(str::to_owned)) + .collect() + }; + assert_eq!( + run("to_char", "hex"), + [ + Some("537061726B2053514C".to_owned()), + Some("616263".to_owned()), + None + ] + ); + assert_eq!(run("to_varchar", " HEX ")[1].as_deref(), Some("616263")); + assert_eq!( + run("to_char", "utf-8"), + [Some("Spark SQL".to_owned()), Some("abc".to_owned()), None] + ); + assert_eq!(run("to_char", "base64")[1].as_deref(), Some("YWJj")); +} diff --git a/crates/krishiv-functions/src/scalar/xml.rs b/crates/krishiv-functions/src/scalar/xml.rs index ec76ce94b..44ee785a3 100644 --- a/crates/krishiv-functions/src/scalar/xml.rs +++ b/crates/krishiv-functions/src/scalar/xml.rs @@ -74,15 +74,8 @@ enum Mode { /// XML source options (lower case) that Spark defines and this module does not /// implement. const UNIMPLEMENTED: &[&str] = &[ - "samplingratio", - "excludeattribute", "treatemptyvaluesasnulls", - "columnnameofcorruptrecord", - "charset", - "wildcardcolname", "rowvalidationxsdpath", - "ignorenamespace", - "locale", "arrayelementname", "nanvalue", "positiveinf", @@ -106,6 +99,10 @@ struct Opts { infer_schema: bool, /// `schema_of_xml`: infer decimals for numbers with a fraction. prefers_decimal: bool, + /// `schema_of_xml`: ignore attributes (an element with attributes and a text is its text). + exclude_attribute: bool, + /// `schema_of_xml`: element and attribute names lose their namespace prefix (`ns:a` is `a`). + ignore_namespace: bool, /// `to_xml`: refuse element and attribute names that are not XML names. validate_name: bool, date: Option, @@ -126,6 +123,8 @@ impl Opts { indent: None, infer_schema: true, prefers_decimal: false, + exclude_attribute: false, + ignore_namespace: false, validate_name: true, date: None, time: None, @@ -166,7 +165,15 @@ impl Opts { }; } "attributeprefix" => o.attribute_prefix = v.clone(), - "valuetag" => o.value_tag = v.clone(), + "valuetag" => { + if v.is_empty() { + return Err(unsupported( + func, + "an empty valueTag (Spark: 'valueTag' option should not be empty string)", + )); + } + o.value_tag = v.clone(); + } "rowtag" => o.row_tag = v.clone(), "nullvalue" => o.null_value = Some(v.clone()), "ignoresurroundingspaces" => { @@ -182,6 +189,37 @@ impl Opts { "declaration" | "encoding" => {} "inferschema" => o.infer_schema = flag(v, func, "inferSchema")?, "prefersdecimal" => o.prefers_decimal = flag(v, func, "prefersDecimal")?, + // Read by the schema inference only: `from_xml` would have to skip attributes too. + "excludeattribute" if func == "schema_of_xml" => { + o.exclude_attribute = flag(v, func, "excludeAttribute")?; + } + "ignorenamespace" if func == "schema_of_xml" => { + o.ignore_namespace = flag(v, func, "ignoreNamespace")?; + } + // `samplingRatio` must be a number above 0 (Spark: `requirement failed: samplingRatio (x) should be greater than 0`). + "samplingratio" if func == "schema_of_xml" => match v.trim().parse::() { + Ok(r) if r > 0.0 && r.is_finite() => {} + _ => { + return Err(unsupported( + func, + &format!("samplingRatio {v} (it must be a number above 0)"), + )); + } + }, + // Accepted by Spark's XML source and without effect on an inferred schema (Spark 4.2.0 run). + "columnnameofcorruptrecord" | "wildcardcolname" | "charset" + if func == "schema_of_xml" => {} + // `locale` changes how numbers are inferred (`1,5` is a decimal in `de-DE`): only the default is implemented. + "locale" + if func == "schema_of_xml" + && v.trim().replace('_', "-").eq_ignore_ascii_case("en-US") => {} + "samplingratio" + | "columnnameofcorruptrecord" + | "wildcardcolname" + | "charset" + | "locale" + | "ignorenamespace" + | "excludeattribute" => return Err(unsupported(func, &format!("option {k}"))), "validatename" => o.validate_name = flag(v, func, "validateName")?, // Names Spark's XML source defines and this module does not // implement: refused, not silently ignored. @@ -210,6 +248,14 @@ fn flag(v: &str, func: &str, name: &str) -> Result { } else if v.eq_ignore_ascii_case("false") { Ok(false) } else { + // `schema_of_xml` (Spark 4.2.0 runs, goldens #15 and #165): `_LEGACY_ERROR_TEMP_2147` naming the option; the other options and + // functions keep the refusal (Spark gives `prefersDecimal` a classless exception, and nothing is recorded for the rest). + if func == "schema_of_xml" && matches!(name, "excludeAttribute" | "inferSchema") { + return Err(krishiv_common::error::LegacyErrorTemp2147 { + param_name: name.to_owned(), + } + .into()); + } Err(unsupported( func, &format!("option {name}={v} (it must be true or false)"), @@ -1304,10 +1350,10 @@ fn infer_leaf(raw: &str, o: &Opts) -> T { T::Str } -/// `(precision, scale)` of a plain decimal text (`1.5`, `-.25`), else `None`. +/// `(precision, scale)` of a plain decimal text (`1.5`, `-.25`, an integer beyond `long`), else `None`. fn decimal_shape(text: &str) -> Option<(u32, u32)> { let body = text.strip_prefix(['+', '-']).unwrap_or(text); - let (int, frac) = body.split_once('.')?; + let (int, frac) = body.split_once('.').unwrap_or((body, "")); if !int.bytes().all(|b| b.is_ascii_digit()) || !frac.bytes().all(|b| b.is_ascii_digit()) { return None; } @@ -1319,31 +1365,48 @@ fn decimal_shape(text: &str) -> Option<(u32, u32)> { } /// The type both `a` and `b` can be read as. -fn merge(a: T, b: T) -> T { +fn merge(a: T, b: T, tag: &str) -> T { match (a, b) { (T::Null, x) | (x, T::Null) => x, (x, y) if x == y => x, - // A decimal that meets another number is read as a double. - (T::Long, T::Double) - | (T::Double, T::Long) - | (T::Decimal(..), T::Long | T::Double | T::Decimal(..)) - | (T::Long | T::Double, T::Decimal(..)) => T::Double, + (T::Long | T::Decimal(..), T::Double) | (T::Double, T::Long | T::Decimal(..)) => T::Double, + // Decimals (a `long` counts as DECIMAL(20,0)) widen to the scale and integer digits of the larger: `1.5` and `2` give + // DECIMAL(21,1); past 38 digits they are a double. + (T::Decimal(p1, s1), T::Decimal(p2, s2)) => widen_decimal(p1, s1, p2, s2), + (T::Decimal(p, s), T::Long) | (T::Long, T::Decimal(p, s)) => widen_decimal(p, s, 20, 0), (T::Date, T::Timestamp) | (T::Timestamp, T::Date) => T::Timestamp, - (T::Array(x), T::Array(y)) => T::Array(Box::new(merge(*x, *y))), - (T::Array(x), y) | (y, T::Array(x)) => T::Array(Box::new(merge(*x, y))), - (T::Struct(x), T::Struct(y)) => T::Struct(merge_fields(x, y)), + (T::Array(x), T::Array(y)) => T::Array(Box::new(merge(*x, *y, tag))), + (T::Array(x), y) | (y, T::Array(x)) => T::Array(Box::new(merge(*x, y, tag))), + (T::Struct(x), T::Struct(y)) => T::Struct(merge_fields(x, y, tag)), + // An element with attributes or children meets one that is a bare value: the value joins the struct as its value tag. + (T::Struct(x), y) | (y, T::Struct(x)) + if x.iter().any(|(n, _)| n.eq_ignore_ascii_case(tag)) => + { + T::Struct(merge_fields(x, vec![(tag.to_owned(), y)], tag)) + } _ => T::Str, } } +/// The decimal both can be read as: the larger scale and the larger count of integer digits, a double past 38 digits. +fn widen_decimal(p1: u32, s1: u32, p2: u32, s2: u32) -> T { + let scale = s1.max(s2); + let range = (p1 - s1).max(p2 - s2); + if range + scale > 38 { + T::Double + } else { + T::Decimal(range + scale, scale) + } +} + /// The union of two field lists; names match without regard to case and the /// first spelling stays. -fn merge_fields(mut a: Vec<(String, T)>, b: Vec<(String, T)>) -> Vec<(String, T)> { +fn merge_fields(mut a: Vec<(String, T)>, b: Vec<(String, T)>, tag: &str) -> Vec<(String, T)> { for (name, t) in b { match a.iter().position(|(n, _)| n.eq_ignore_ascii_case(&name)) { Some(i) => { let old = std::mem::replace(&mut a[i].1, T::Null); - a[i].1 = merge(old, t); + a[i].1 = merge(old, t, tag); } None => a.push((name, t)), } @@ -1355,37 +1418,57 @@ fn merge_fields(mut a: Vec<(String, T)>, b: Vec<(String, T)>) -> Vec<(String, T) /// children (repeated children are arrays). fn infer_elem(e: &Elem, o: &Opts, root: bool) -> T { let text_blank = e.text.trim().is_empty(); - if e.attrs.is_empty() && e.children.is_empty() && !root { + let attrs: &[(String, String)] = if o.exclude_attribute { &[] } else { &e.attrs }; + let local = |n: &str| -> String { + if o.ignore_namespace { + n.rsplit_once(':').map_or(n, |(_, l)| l).to_owned() + } else { + n.to_owned() + } + }; + if attrs.is_empty() && e.children.is_empty() && !root { return infer_leaf(&e.text, o); } let mut fields: Vec<(String, T)> = Vec::new(); - for (k, v) in &e.attrs { + for (k, v) in attrs { fields = merge_fields( fields, - vec![(format!("{}{k}", o.attribute_prefix), infer_leaf(v, o))], + vec![( + format!("{}{}", o.attribute_prefix, local(k)), + infer_leaf(v, o), + )], + &o.value_tag, ); } if !text_blank { - fields = merge_fields(fields, vec![(o.value_tag.clone(), infer_leaf(&e.text, o))]); + fields = merge_fields( + fields, + vec![(o.value_tag.clone(), infer_leaf(&e.text, o))], + &o.value_tag, + ); } let mut seen: Vec<(String, T, usize)> = Vec::new(); + // Child names are compared case-insensitively: one lower-cased key per child, looked up in a map, not searched for in a list. + let mut index: std::collections::HashMap = std::collections::HashMap::new(); for c in &e.children { let t = infer_elem(c, o, false); - match seen - .iter() - .position(|(n, _, _)| n.eq_ignore_ascii_case(&c.name)) - { - Some(i) => { + let name = local(&c.name); + let key = name.to_lowercase(); + match index.get(&key) { + Some(&i) => { let old = std::mem::replace(&mut seen[i].1, T::Null); - seen[i].1 = merge(old, t); + seen[i].1 = merge(old, t, &o.value_tag); seen[i].2 += 1; } - None => seen.push((c.name.clone(), t, 1)), + None => { + index.insert(key, seen.len()); + seen.push((name, t, 1)); + } } } for (name, t, n) in seen { let t = if n > 1 { T::Array(Box::new(t)) } else { t }; - fields = merge_fields(fields, vec![(name, t)]); + fields = merge_fields(fields, vec![(name, t)], &o.value_tag); } T::Struct(fields) } diff --git a/crates/krishiv-plan/src/analyzer/hof.rs b/crates/krishiv-plan/src/analyzer/hof.rs index 05ae22674..928b378c5 100644 --- a/crates/krishiv-plan/src/analyzer/hof.rs +++ b/crates/krishiv-plan/src/analyzer/hof.rs @@ -161,7 +161,8 @@ impl Hof { if position == 2 && matches!(self, Self::Aggregate | Self::Reduce) { return (2, 2); } - if position == 1 && matches!(self, Self::Transform) { + // `transform` and `filter` take an optional element index: `(x, i) -> ...`. + if position == 1 && matches!(self, Self::Transform | Self::Filter) { return (1, 2); } match self { @@ -528,14 +529,14 @@ impl Resolver<'_> { }); }; match h { - Hof::Transform => { + Hof::Transform | Hof::Filter => { let (element, contains) = array_element(0); var(params[0].clone(), element, contains); if params.len() == 2 { var(params[1].clone(), DataType::Integer, false); } } - Hof::Filter | Hof::Exists | Hof::ForAll => { + Hof::Exists | Hof::ForAll => { let (element, contains) = array_element(0); var(params[0].clone(), element, contains); } diff --git a/crates/krishiv-session/tests/higher_order.rs b/crates/krishiv-session/tests/higher_order.rs index 21c85d45e..ffd7c9db2 100644 --- a/crates/krishiv-session/tests/higher_order.rs +++ b/crates/krishiv-session/tests/higher_order.rs @@ -281,6 +281,24 @@ fn filter_keeps_true_elements() { ); } +/// SQL-4: `filter` with the element index, `(x, i) -> ...` (Spark 4.2.0: `[2, 3]`). +#[test] +fn filter_takes_the_element_index() { + let s = session(); + assert_eq!( + strings(&s, "filter(array(0, 2, 3), (x, i) -> x > i)", ""), + [Some("[2, 3]".to_owned())] + ); + assert_eq!( + strings(&s, "filter(array(10, 20, 30, 40), (x, i) -> i % 2 = 0)", ""), + [Some("[10, 30]".to_owned())] + ); + assert_eq!( + strings(&s, "filter(array(5, NULL, 7), (x, i) -> i > 0)", ""), + [Some("[null, 7]".to_owned())] + ); +} + #[test] fn exists_and_forall_fold_the_marks() { let s = session(); @@ -474,13 +492,13 @@ fn constant_lambdas_of_the_wrong_type_are_rejected() { #[test] fn lambda_shapes_are_checked() { let s = session(); - // `transform` takes one or two variables, the others exactly one. + // `transform` and `filter` take one or two variables, the others exactly one. let e = error(&s, "SELECT transform(ys, (a, b, c) -> a) FROM t"); assert_eq!( e.error_class(), ErrorClass::InvalidLambdaFunctionCallNumArgsMismatch ); - let e = error(&s, "SELECT filter(ys, (a, b) -> a) FROM t"); + let e = error(&s, "SELECT filter(ys, (a, b, c) -> a) FROM t"); assert_eq!( e.error_class(), ErrorClass::InvalidLambdaFunctionCallNumArgsMismatch diff --git a/crates/krishiv-session/tests/schema_of_xml_goldens.rs b/crates/krishiv-session/tests/schema_of_xml_goldens.rs new file mode 100644 index 000000000..712d00ed9 --- /dev/null +++ b/crates/krishiv-session/tests/schema_of_xml_goldens.rs @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: Apache-2.0 +//! `schema_of_xml` with options against the Spark 4.2.0 run in `tests/spark-golden/functions/sequence_xml/results/` +//! (SQL-6): every statement of the case files runs in order in one session; a statement whose Spark output is a value is compared +//! as text, one whose output is an exception must fail here too (the messages are not compared). The statements that still differ +//! are listed in `KNOWN_GAPS` and must keep differing (a ratchet, as the golden runner's). +#![cfg(test)] + +use arrow_array::Array; +use arrow_array::cast::AsArray; +use futures::executor::block_on; +use krishiv_session::Session; + +const FILES: &[&str] = &["schema_of_xml"]; + +/// `file#n` (1-based statement number) the engine does not match yet; each is a Spark quirk or a missing feature named in the +/// golden README. +const KNOWN_GAPS: &[&str] = &[ + // Duplicate field names (`attributePrefix=''` with `valueTag='attr'`): Spark keeps both fields, this keeps one. + "schema_of_xml#11", + // A non-literal options map: Spark fails with INTERNAL_ERROR (a Spark bug, recorded in the golden README); this reads it as given. + "schema_of_xml#37", + "schema_of_xml#38", + // Text split by child elements (`textmore`) is `_VALUE: ARRAY<...>` in Spark. + "schema_of_xml#73", + "schema_of_xml#74", + "schema_of_xml#75", + // `nullValue` text in an array of values: 4.2.0 reads it as a string (`ARRAY`), 4.3.0 as null (`ARRAY`); this is 4.3.0's. + "schema_of_xml#130", + "schema_of_xml#132", + // `locale` for numbers (`1,5`), an invalid `timeZone` and FAILFAST on an unclosed document: options not read here yet. + "schema_of_xml#162", + "schema_of_xml#163", + "schema_of_xml#168", + "schema_of_xml#183", + // `from_xml` with `excludeAttribute`: the reader does not skip attributes yet (refused as unsupported). + "schema_of_xml#200", +]; + +struct Case { + sql: String, + output: String, +} + +fn cases(file: &str) -> Vec { + let path = format!( + "{}/../../tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/{file}.sql.out", + env!("CARGO_MANIFEST_DIR") + ); + let text = std::fs::read_to_string(path).expect("golden file"); + let mut out = Vec::new(); + for block in text.split("-- !query\n").skip(1) { + let (sql, rest) = block + .split_once("-- !query schema\n") + .expect("schema marker"); + let (_, output) = rest + .split_once("-- !query output\n") + .expect("output marker"); + out.push(Case { + sql: sql.trim().to_owned(), + output: output.trim().to_owned(), + }); + } + out +} + +fn is_error(output: &str) -> bool { + output.starts_with("org.apache.") || output.starts_with("java.") || output.starts_with("scala.") +} + +fn render(s: &Session, sql: &str) -> Result, krishiv_common::error::KrishivError> { + // Every column is cast to a string (a tab joins them), so a statement of any width is compared as Spark prints it. + let width = block_on(block_on(s.sql(sql))?.schema())?.fields().len(); + let names: Vec = (0..width).map(|i| format!("c{i}")).collect(); + let casts: Vec = names + .iter() + .map(|n| format!("CAST({n} AS STRING)")) + .collect(); + let wrapped = format!( + "SELECT {} FROM ({sql}) AS t({})", + casts.join(", "), + names.join(", ") + ); + let df = block_on(s.sql(&wrapped))?; + let batches = block_on(df.collect())?; + let mut rows = Vec::new(); + for b in &batches { + for i in 0..b.num_rows() { + let cells: Vec = (0..width) + .map(|c| { + let col = b.column(c).as_string_view(); + if col.is_null(i) { + "NULL".to_owned() + } else { + col.value(i).to_owned() + } + }) + .collect(); + rows.push(cells.join("\t")); + } + } + Ok(rows) +} + +#[test] +fn schema_of_xml_follows_the_spark_runs() { + let mut gaps: Vec = Vec::new(); + for file in FILES { + let s = Session::new().unwrap(); + for (n, case) in cases(file).iter().enumerate() { + let id = format!("{file}#{}", n + 1); + let upper = case.sql.to_ascii_uppercase(); + if !upper.starts_with("SELECT") { + // SET, CREATE VIEW ...: run for their effect. + // A setup statement that Spark ran must run here too, or the later results mean nothing. + let done = block_on(s.sql(&case.sql)).and_then(|df| block_on(df.collect())); + if let Err(e) = done + && !is_error(&case.output) + { + panic!("setup statement {id} failed: {}: {e:?}", case.sql); + } + continue; + } + let got = render(&s, &case.sql); + let ok = if is_error(&case.output) { + // A failure, and when Spark names an error class (a `_LEGACY_ERROR_TEMP_*` too) the same class; only an exception + // without a class is checked as a failure alone. + let want = case + .output + .lines() + .find_map(|l| l.strip_prefix("errorClass: ")) + .map(|c| c.trim().to_owned()); + match (&got, want) { + (Err(e), Some(c)) => e.error_class().name() == c, + (Err(_), _) => true, + _ => false, + } + } else { + match &got { + Ok(rows) => rows.join("\n") == case.output, + Err(_) => false, + } + }; + if !ok { + gaps.push(format!("{id}: {}", case.sql)); + eprintln!( + "MISMATCH {id}: {}\n want {}\n got {got:?}", + case.sql, case.output + ); + } + } + } + let ids: Vec<&str> = gaps + .iter() + .map(|g| g.split(':').next().unwrap_or("")) + .collect(); + assert_eq!(ids, KNOWN_GAPS, "mismatches: {gaps:#?}"); +} diff --git a/crates/krishiv-session/tests/sequence_goldens.rs b/crates/krishiv-session/tests/sequence_goldens.rs new file mode 100644 index 000000000..4dcca9758 --- /dev/null +++ b/crates/krishiv-session/tests/sequence_goldens.rs @@ -0,0 +1,157 @@ +// SPDX-License-Identifier: Apache-2.0 +//! `sequence` over dates and timestamps against the Spark 4.2.0 runs in `tests/spark-golden/functions/sequence_xml/results/` +//! (SQL-6): every statement of the case files runs in order in one session; a statement whose Spark output is a value is compared +//! as text, one whose output is an exception must fail here too (the messages are not compared). The statements that still differ +//! are listed in `KNOWN_GAPS` and must keep differing (a ratchet, as the golden runner's). +#![cfg(test)] + +use arrow_array::Array; +use arrow_array::cast::AsArray; +use futures::executor::block_on; +use krishiv_session::Session; + +const FILES: &[&str] = &[ + "sequence_dates", + "sequence_timestamps", + "sequence_tz", + "sequence_calendar", + "sequence_errors", +]; + +/// `file#n` (1-based statement number) the engine does not match yet; each is a Spark quirk or a missing feature named in the +/// golden README. +const KNOWN_GAPS: &[&str] = &[ + // TIMESTAMP beside TIMESTAMP_NTZ: Spark casts the NTZ bound; the registry's input rule does not yet. + "sequence_timestamps#49", + // `spark.sql.legacy.interval.enabled` interval literals (`interval 1 month 2 days`, `interval 6 hours` as CALENDAR): a parser feature. + "sequence_calendar#68", + "sequence_calendar#69", + "sequence_calendar#70", + "sequence_calendar#71", + "sequence_calendar#72", + "sequence_calendar#73", + "sequence_calendar#74", + // The same legacy-interval mode with a DAY TO SECOND or zero-month step over dates: the literal is refused before the step is checked. + "sequence_calendar#75", + "sequence_calendar#76", +]; + +struct Case { + sql: String, + output: String, +} + +fn cases(file: &str) -> Vec { + let path = format!( + "{}/../../tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/{file}.sql.out", + env!("CARGO_MANIFEST_DIR") + ); + let text = std::fs::read_to_string(path).expect("golden file"); + let mut out = Vec::new(); + for block in text.split("-- !query\n").skip(1) { + let (sql, rest) = block + .split_once("-- !query schema\n") + .expect("schema marker"); + let (_, output) = rest + .split_once("-- !query output\n") + .expect("output marker"); + out.push(Case { + sql: sql.trim().to_owned(), + output: output.trim().to_owned(), + }); + } + out +} + +fn is_error(output: &str) -> bool { + output.starts_with("org.apache.") || output.starts_with("java.") || output.starts_with("scala.") +} + +fn render(s: &Session, sql: &str) -> Result, krishiv_common::error::KrishivError> { + // Every column is cast to a string (a tab joins them), so a statement of any width is compared as Spark prints it. + let width = block_on(block_on(s.sql(sql))?.schema())?.fields().len(); + let names: Vec = (0..width).map(|i| format!("c{i}")).collect(); + let casts: Vec = names + .iter() + .map(|n| format!("CAST({n} AS STRING)")) + .collect(); + let wrapped = format!( + "SELECT {} FROM ({sql}) AS t({})", + casts.join(", "), + names.join(", ") + ); + let df = block_on(s.sql(&wrapped))?; + let batches = block_on(df.collect())?; + let mut rows = Vec::new(); + for b in &batches { + for i in 0..b.num_rows() { + let cells: Vec = (0..width) + .map(|c| { + let col = b.column(c).as_string_view(); + if col.is_null(i) { + "NULL".to_owned() + } else { + col.value(i).to_owned() + } + }) + .collect(); + rows.push(cells.join("\t")); + } + } + Ok(rows) +} + +#[test] +fn sequence_over_dates_and_timestamps_follows_the_spark_runs() { + let mut gaps: Vec = Vec::new(); + for file in FILES { + let s = Session::new().unwrap(); + for (n, case) in cases(file).iter().enumerate() { + let id = format!("{file}#{}", n + 1); + let upper = case.sql.to_ascii_uppercase(); + if !upper.starts_with("SELECT") { + // SET, CREATE VIEW ...: run for their effect. + // A setup statement that Spark ran must run here too, or the later results mean nothing. + let done = block_on(s.sql(&case.sql)).and_then(|df| block_on(df.collect())); + if let Err(e) = done + && !is_error(&case.output) + { + panic!("setup statement {id} failed: {}: {e:?}", case.sql); + } + continue; + } + let got = render(&s, &case.sql); + let ok = if is_error(&case.output) { + // A failure, and when Spark names an error class (a `_LEGACY_ERROR_TEMP_*` too) the same class; only an exception + // without a class is checked as a failure alone. + let want = case + .output + .lines() + .find_map(|l| l.strip_prefix("errorClass: ")) + .map(|c| c.trim().to_owned()); + match (&got, want) { + (Err(e), Some(c)) => e.error_class().name() == c, + (Err(_), _) => true, + _ => false, + } + } else { + match &got { + Ok(rows) => rows.join("\n") == case.output, + Err(_) => false, + } + }; + if !ok { + gaps.push(format!("{id}: {}", case.sql)); + eprintln!( + "MISMATCH {id}: {}\n want {}\n got {got:?}", + case.sql, case.output + ); + } + } + } + let ids: Vec<&str> = gaps + .iter() + .map(|g| g.split(':').next().unwrap_or("")) + .collect(); + assert_eq!(ids, KNOWN_GAPS, "mismatches: {gaps:#?}"); +} diff --git a/crates/krishiv-session/tests/xml_functions.rs b/crates/krishiv-session/tests/xml_functions.rs index e387e7992..6f36c0fa3 100644 --- a/crates/krishiv-session/tests/xml_functions.rs +++ b/crates/krishiv-session/tests/xml_functions.rs @@ -577,11 +577,19 @@ fn schema_of_xml_errors_and_from_xml_of_it() { class_of(&s, "select schema_of_xml('

', map('a', 1))"), ErrorClass::InvalidOptionsNonStringType ); + // `samplingRatio` and the like are accepted by `schema_of_xml` (no effect on an inferred schema); an option still unimplemented is refused. assert_eq!( - class_of( + run( &s, "select schema_of_xml('

', map('samplingRatio', '0.5'))" ), + run(&s, "select schema_of_xml('

')") + ); + assert_eq!( + class_of( + &s, + "select schema_of_xml('

', map('rowValidationXSDPath', 'x.xsd'))" + ), ErrorClass::KrishivUnsupportedFeature ); let s2 = session(); @@ -689,19 +697,32 @@ fn to_xml_wraps_inner_arrays_in_item_elements() { #[test] fn option_values_and_schemas() { let s = session(); - // Spark refuses a flag that is not true or false; an unknown mode reads as PERMISSIVE. - for options in [ - "'ignoreSurroundingSpaces', 'maybe'", - "'inferSchema', 'maybe'", - "'prefersDecimal', 'maybe'", - "'validateName', 'maybe'", + // Spark refuses a flag that is not true or false (`_LEGACY_ERROR_TEMP_2147`, golden schema_of_xml#165); an unknown mode reads as PERMISSIVE. + for (options, class) in [ + ( + "'ignoreSurroundingSpaces', 'maybe'", + ErrorClass::KrishivUnsupportedFeature, + ), + ("'inferSchema', 'maybe'", ErrorClass::LegacyErrorTemp2147), + ( + "'excludeAttribute', 'maybe'", + ErrorClass::LegacyErrorTemp2147, + ), + ( + "'prefersDecimal', 'maybe'", + ErrorClass::KrishivUnsupportedFeature, + ), + ( + "'validateName', 'maybe'", + ErrorClass::KrishivUnsupportedFeature, + ), ] { assert_eq!( class_of( &s, &format!("select schema_of_xml('

1

', map({options}))") ), - ErrorClass::KrishivUnsupportedFeature, + class, "{options}" ); } diff --git a/docs/reference/sql/functions/_examples.json b/docs/reference/sql/functions/_examples.json index b772920bf..62b6105fe 100644 --- a/docs/reference/sql/functions/_examples.json +++ b/docs/reference/sql/functions/_examples.json @@ -1650,8 +1650,10 @@ ] }, "filter#2": { - "class": "INVALID_LAMBDA_FUNCTION_CALL.NUM_ARGS_MISMATCH", - "ok": false + "ok": true, + "rows": [ + "[2,3]" + ] }, "filter#3": { "ok": true, @@ -4425,8 +4427,10 @@ ] }, "reverse#2": { - "class": "DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE", - "ok": false + "ok": true, + "rows": [ + "[3,4,1,2]" + ] }, "reverse#3": { "ok": true, @@ -4574,8 +4578,10 @@ ] }, "schema_of_xml#2": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "STRUCT>" + ] }, "sec#1": { "ok": true, @@ -4620,12 +4626,16 @@ ] }, "sequence#3": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "[2018-01-01,2018-02-01,2018-03-01]" + ] }, "sequence#4": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "[2018-01-01,2018-02-01,2018-03-01]" + ] }, "session_user#1": { "volatile": true @@ -5460,16 +5470,22 @@ ] }, "to_char#7": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "U3BhcmsgU1FM" + ] }, "to_char#8": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "537061726B2053514C" + ] }, "to_char#9": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "abc" + ] }, "to_csv#1": { "ok": true, @@ -5674,16 +5690,22 @@ ] }, "to_varchar#7": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "U3BhcmsgU1FM" + ] }, "to_varchar#8": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "537061726B2053514C" + ] }, "to_varchar#9": { - "class": "KRISHIV_UNSUPPORTED_FEATURE", - "ok": false + "ok": true, + "rows": [ + "abc" + ] }, "to_variant_object#1": { "ok": true, diff --git a/docs/reference/sql/functions/filter.md b/docs/reference/sql/functions/filter.md index 9f4a75b08..b7f5a543e 100644 --- a/docs/reference/sql/functions/filter.md +++ b/docs/reference/sql/functions/filter.md @@ -35,7 +35,7 @@ filter(expr, func) ```sql -- filter, example 2 > SELECT filter(array(0, 2, 3), (x, i) -> x > i); -Error: INVALID_LAMBDA_FUNCTION_CALL.NUM_ARGS_MISMATCH +[2,3] ``` ```sql diff --git a/docs/reference/sql/functions/reverse.md b/docs/reference/sql/functions/reverse.md index 14a3be547..75f8ca21c 100644 --- a/docs/reference/sql/functions/reverse.md +++ b/docs/reference/sql/functions/reverse.md @@ -36,7 +36,7 @@ LQS krapS ```sql -- reverse, example 2 > SELECT reverse(array(2, 1, 4, 3)); -Error: DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE +[3,4,1,2] ``` ```sql diff --git a/docs/reference/sql/functions/schema_of_xml.md b/docs/reference/sql/functions/schema_of_xml.md index 91472c97a..8ae3202eb 100644 --- a/docs/reference/sql/functions/schema_of_xml.md +++ b/docs/reference/sql/functions/schema_of_xml.md @@ -35,7 +35,7 @@ STRUCT ```sql -- schema_of_xml, example 2 > SELECT schema_of_xml('

13

', map('excludeAttribute', 'true')); -Error: KRISHIV_UNSUPPORTED_FEATURE +STRUCT> ``` ## Version history diff --git a/docs/reference/sql/functions/sequence.md b/docs/reference/sql/functions/sequence.md index 3b44c6a22..ac9f8b74b 100644 --- a/docs/reference/sql/functions/sequence.md +++ b/docs/reference/sql/functions/sequence.md @@ -50,13 +50,13 @@ sequence(start, stop, step) ```sql -- sequence, example 3 > SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month); -Error: KRISHIV_UNSUPPORTED_FEATURE +[2018-01-01,2018-02-01,2018-03-01] ``` ```sql -- sequence, example 4 > SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month); -Error: KRISHIV_UNSUPPORTED_FEATURE +[2018-01-01,2018-02-01,2018-03-01] ``` ## Version history diff --git a/docs/reference/sql/functions/to_char.md b/docs/reference/sql/functions/to_char.md index a2d60755c..20ab0acfd 100644 --- a/docs/reference/sql/functions/to_char.md +++ b/docs/reference/sql/functions/to_char.md @@ -89,19 +89,19 @@ $78.12 ```sql -- to_char, example 7 > SELECT to_char(x'537061726b2053514c', 'base64'); -Error: KRISHIV_UNSUPPORTED_FEATURE +U3BhcmsgU1FM ``` ```sql -- to_char, example 8 > SELECT to_char(x'537061726b2053514c', 'hex'); -Error: KRISHIV_UNSUPPORTED_FEATURE +537061726B2053514C ``` ```sql -- to_char, example 9 > SELECT to_char(encode('abc', 'utf-8'), 'utf-8'); -Error: KRISHIV_UNSUPPORTED_FEATURE +abc ``` ## Version history diff --git a/docs/reference/sql/functions/to_varchar.md b/docs/reference/sql/functions/to_varchar.md index 81b7c4fd1..184895741 100644 --- a/docs/reference/sql/functions/to_varchar.md +++ b/docs/reference/sql/functions/to_varchar.md @@ -89,19 +89,19 @@ $78.12 ```sql -- to_varchar, example 7 > SELECT to_varchar(x'537061726b2053514c', 'base64'); -Error: KRISHIV_UNSUPPORTED_FEATURE +U3BhcmsgU1FM ``` ```sql -- to_varchar, example 8 > SELECT to_varchar(x'537061726b2053514c', 'hex'); -Error: KRISHIV_UNSUPPORTED_FEATURE +537061726B2053514C ``` ```sql -- to_varchar, example 9 > SELECT to_varchar(encode('abc', 'utf-8'), 'utf-8'); -Error: KRISHIV_UNSUPPORTED_FEATURE +abc ``` ## Version history diff --git a/python/tests/test_functions_lambdas.py b/python/tests/test_functions_lambdas.py index e7329b6f3..fe7c893ab 100644 --- a/python/tests/test_functions_lambdas.py +++ b/python/tests/test_functions_lambdas.py @@ -71,7 +71,6 @@ def test_lambda_variables_do_not_capture_columns() -> None: assert one(d, F.aggregate("arr", F.lit(0), lambda acc, x: acc + x + F.col("y_0"))) == 2003 -@pytest.mark.xfail(reason="the engine's filter takes no index lambda: INVALID_LAMBDA_FUNCTION_CALL", strict=True) def test_filter_with_an_index_lambda(df: DataFrame) -> None: assert one(df, F.filter("arr", lambda x, i: i > 0)) == [1, 2] diff --git a/tests/fixtures/analysis/registry-matrix/filter.json b/tests/fixtures/analysis/registry-matrix/filter.json deleted file mode 100644 index 2680193a5..000000000 --- a/tests/fixtures/analysis/registry-matrix/filter.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "entries": [ - { - "id": "filter#cc869a817020/ansi_on", - "reason": "SELECT filter(array(0, 2, 3), (x, i) -> x > i) | INVALID_LAMBDA_FUNCTION_CALL.NUM_ARGS_MISMATCH" - }, - { - "id": "filter#cc869a817020/ansi_off", - "reason": "SELECT filter(array(0, 2, 3), (x, i) -> x > i) | INVALID_LAMBDA_FUNCTION_CALL.NUM_ARGS_MISMATCH" - } - ], - "format_version": 1, - "function": "filter" -} diff --git a/tests/fixtures/analysis/registry-matrix/reverse.json b/tests/fixtures/analysis/registry-matrix/reverse.json deleted file mode 100644 index 5cb572331..000000000 --- a/tests/fixtures/analysis/registry-matrix/reverse.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "entries": [ - { - "id": "reverse#1eeb8d128702/ansi_on", - "reason": "SELECT reverse(array(1, 2)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#1eeb8d128702/ansi_off", - "reason": "SELECT reverse(array(1, 2)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#27d73e6b9b7a/ansi_on", - "reason": "SELECT reverse(CAST(array(NULL) AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#27d73e6b9b7a/ansi_off", - "reason": "SELECT reverse(CAST(array(NULL) AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#58b4d7850388/ansi_on", - "reason": "SELECT reverse(array(2, 1, 4, 3)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#58b4d7850388/ansi_off", - "reason": "SELECT reverse(array(2, 1, 4, 3)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#61dbbe3b92fa/ansi_on", - "reason": "SELECT reverse(CAST(NULL AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#61dbbe3b92fa/ansi_off", - "reason": "SELECT reverse(CAST(NULL AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#6d11d9d7634a/ansi_on", - "reason": "SELECT reverse(CAST(array() AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - }, - { - "id": "reverse#6d11d9d7634a/ansi_off", - "reason": "SELECT reverse(CAST(array() AS array)) | DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" - } - ], - "format_version": 1, - "function": "reverse" -} diff --git a/tests/fixtures/analysis/registry-matrix/schema_of_xml.json b/tests/fixtures/analysis/registry-matrix/schema_of_xml.json index d712324e8..2173c5ba2 100644 --- a/tests/fixtures/analysis/registry-matrix/schema_of_xml.json +++ b/tests/fixtures/analysis/registry-matrix/schema_of_xml.json @@ -8,14 +8,6 @@ "id": "schema_of_xml#07b9e7c09b35/ansi_off", "reason": "SELECT schema_of_xml(array(1, 2), map('excludeAttribute', 'true')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" }, - { - "id": "schema_of_xml#10141e3af409/ansi_on", - "reason": "SELECT schema_of_xml('', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#10141e3af409/ansi_off", - "reason": "SELECT schema_of_xml('', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, { "id": "schema_of_xml#1fff726835a7/ansi_on", "reason": "SELECT schema_of_xml(map('a', 1)) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" @@ -24,14 +16,6 @@ "id": "schema_of_xml#1fff726835a7/ansi_off", "reason": "SELECT schema_of_xml(map('a', 1)) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" }, - { - "id": "schema_of_xml#2ac077691275/ansi_on", - "reason": "SELECT schema_of_xml('Ä€日本語😀é', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#2ac077691275/ansi_off", - "reason": "SELECT schema_of_xml('Ä€日本語😀é', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, { "id": "schema_of_xml#3febfd35b2ea/ansi_on", "reason": "SELECT schema_of_xml(map('a', 1), map('excludeAttribute', 'true')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" @@ -48,14 +32,6 @@ "id": "schema_of_xml#7f504ef0c560/ansi_off", "reason": "SELECT schema_of_xml(CAST(X'C328FF' AS STRING), map('excludeAttribute', 'true')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT" }, - { - "id": "schema_of_xml#924b83cc2ad2/ansi_on", - "reason": "SELECT schema_of_xml('

13

', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#924b83cc2ad2/ansi_off", - "reason": "SELECT schema_of_xml('

13

', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, { "id": "schema_of_xml#a6fa74796cd3/ansi_on", "reason": "SELECT schema_of_xml(named_struct('a', 1, 'b', 'x')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" @@ -64,22 +40,6 @@ "id": "schema_of_xml#a6fa74796cd3/ansi_off", "reason": "SELECT schema_of_xml(named_struct('a', 1, 'b', 'x')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" }, - { - "id": "schema_of_xml#a7ffed60d87d/ansi_on", - "reason": "SELECT schema_of_xml(' \\t a\\u3000\\n ', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#a7ffed60d87d/ansi_off", - "reason": "SELECT schema_of_xml(' \\t a\\u3000\\n ', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#ad4f724c3259/ansi_on", - "reason": "SELECT schema_of_xml('abc', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#ad4f724c3259/ansi_off", - "reason": "SELECT schema_of_xml('abc', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, { "id": "schema_of_xml#bc2d27a18e8e/ansi_on", "reason": "SELECT schema_of_xml(named_struct('a', 1, 'b', 'x'), map('excludeAttribute', 'true')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" @@ -88,14 +48,6 @@ "id": "schema_of_xml#bc2d27a18e8e/ansi_off", "reason": "SELECT schema_of_xml(named_struct('a', 1, 'b', 'x'), map('excludeAttribute', 'true')) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" }, - { - "id": "schema_of_xml#cc58a32f3506/ansi_on", - "reason": "SELECT schema_of_xml('1', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, - { - "id": "schema_of_xml#cc58a32f3506/ansi_off", - "reason": "SELECT schema_of_xml('1', map('excludeAttribute', 'true')) | KRISHIV_UNSUPPORTED_FEATURE: schema_of_xml with option excludeAttribute" - }, { "id": "schema_of_xml#d9be1c6c8c8a/ansi_on", "reason": "SELECT schema_of_xml(array(1, 2)) | DATATYPE_MISMATCH.NON_FOLDABLE_INPUT where Spark has DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE" diff --git a/tests/fixtures/analysis/registry-matrix/sequence.json b/tests/fixtures/analysis/registry-matrix/sequence.json deleted file mode 100644 index d6c9dc364..000000000 --- a/tests/fixtures/analysis/registry-matrix/sequence.json +++ /dev/null @@ -1,654 +0,0 @@ -{ - "entries": [ - { - "id": "sequence#02c0fc6f9ee5/ansi_on", - "reason": "SELECT sequence(INTERVAL '1 02:03:04' DAY TO SECOND, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#02c0fc6f9ee5/ansi_off", - "reason": "SELECT sequence(INTERVAL '1 02:03:04' DAY TO SECOND, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#03e2b1fc2f51/ansi_on", - "reason": "SELECT sequence('abc', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#03e2b1fc2f51/ansi_off", - "reason": "SELECT sequence('abc', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#06185c6e4920/ansi_on", - "reason": "SELECT sequence(map('a', 1), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#06185c6e4920/ansi_off", - "reason": "SELECT sequence(map('a', 1), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#0ffcf0eef171/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), true) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#0ffcf0eef171/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), true) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#129f06f2a5e4/ansi_on", - "reason": "SELECT sequence(1L, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#129f06f2a5e4/ansi_off", - "reason": "SELECT sequence(1L, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#16ed92cbb89f/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'9999-12-31', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#16ed92cbb89f/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'9999-12-31', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#16f6c1e500e2/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS DECIMAL(38,18))) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#16f6c1e500e2/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS DECIMAL(38,18))) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#194e77f7fa69/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), TIMESTAMP'2024-02-29 12:34:56.123456', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#194e77f7fa69/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), TIMESTAMP'2024-02-29 12:34:56.123456', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#19ae27512e39/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'1582-10-10', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#19ae27512e39/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'1582-10-10', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#1fb985976d3e/ansi_on", - "reason": "SELECT sequence(DATE'0001-01-01', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#1fb985976d3e/ansi_off", - "reason": "SELECT sequence(DATE'0001-01-01', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#333b8eb5c05a/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), INTERVAL '1 02:03:04' DAY TO SECOND) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#333b8eb5c05a/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), INTERVAL '1 02:03:04' DAY TO SECOND) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#39cdc9bdbcbc/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), NULL, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#39cdc9bdbcbc/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), NULL, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#3a943e1a900f/ansi_on", - "reason": "SELECT sequence('1', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#3a943e1a900f/ansi_off", - "reason": "SELECT sequence('1', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3b7a7117ff50/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), map('a', 1)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3b7a7117ff50/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), map('a', 1)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3d037bfe6511/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1 AS TINYINT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3d037bfe6511/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1 AS TINYINT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3f54e5aa78fc/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), map('a', 1), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#3f54e5aa78fc/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), map('a', 1), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#40fb2f4656aa/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(NULL AS date), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#40fb2f4656aa/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(NULL AS date), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#414dfc040ed6/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), INTERVAL '1 02:03:04' DAY TO SECOND, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#414dfc040ed6/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), INTERVAL '1 02:03:04' DAY TO SECOND, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#43f5bf83c793/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), TIMESTAMP_NTZ'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#43f5bf83c793/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), TIMESTAMP_NTZ'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#46526c3906e9/ansi_on", - "reason": "SELECT sequence(INTERVAL '1-2' YEAR TO MONTH, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#46526c3906e9/ansi_off", - "reason": "SELECT sequence(INTERVAL '1-2' YEAR TO MONTH, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#46e2f798b10c/ansi_on", - "reason": "SELECT sequence(1, TIMESTAMP'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#46e2f798b10c/ansi_off", - "reason": "SELECT sequence(1, TIMESTAMP'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#480ea34a6c48/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), TIMESTAMP'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#480ea34a6c48/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), TIMESTAMP'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#4cf7afaf4a48/ansi_on", - "reason": "SELECT sequence(NULL, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#4cf7afaf4a48/ansi_off", - "reason": "SELECT sequence(NULL, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#5283efbc7fd1/ansi_on", - "reason": "SELECT sequence(CAST(1.5 AS DECIMAL(38,18)), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#5283efbc7fd1/ansi_off", - "reason": "SELECT sequence(CAST(1.5 AS DECIMAL(38,18)), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#535ff10c9cfd/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), named_struct('a', 1, 'b', 'x')) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#535ff10c9cfd/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), named_struct('a', 1, 'b', 'x')) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#53af25b3917f/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), '1', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#53af25b3917f/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), '1', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#58212d7055b7/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'0001-01-01', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#58212d7055b7/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'0001-01-01', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#59f8663289ea/ansi_on", - "reason": "SELECT sequence(CAST(1 AS TINYINT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#59f8663289ea/ansi_off", - "reason": "SELECT sequence(CAST(1 AS TINYINT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#5f8477d6782b/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'2024-02-29', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#5f8477d6782b/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), DATE'2024-02-29', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#615b34709c82/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), DATE'2024-02-29') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#615b34709c82/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), DATE'2024-02-29') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#6bacdaffbc9e/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS DECIMAL(10,2)), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#6bacdaffbc9e/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS DECIMAL(10,2)), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#6da6fa0a3c4d/ansi_on", - "reason": "SELECT sequence(array(1, 2), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#6da6fa0a3c4d/ansi_off", - "reason": "SELECT sequence(array(1, 2), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#71fa123b2d8f/ansi_on", - "reason": "SELECT sequence(CAST(NULL AS date), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#71fa123b2d8f/ansi_off", - "reason": "SELECT sequence(CAST(NULL AS date), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#73f5c0cc52ff/ansi_on", - "reason": "SELECT sequence(DATE'2024-02-29', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#73f5c0cc52ff/ansi_off", - "reason": "SELECT sequence(DATE'2024-02-29', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#73fa61f78e3b/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), INTERVAL '1-2' YEAR TO MONTH, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#73fa61f78e3b/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), INTERVAL '1-2' YEAR TO MONTH, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#76b36a038253/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), named_struct('a', 1, 'b', 'x'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#76b36a038253/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), named_struct('a', 1, 'b', 'x'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#77660e0c7468/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#77660e0c7468/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#7880fe9b06ae/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS DECIMAL(38,18)), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#7880fe9b06ae/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS DECIMAL(38,18)), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#79ec780a8cab/ansi_on", - "reason": "SELECT sequence(CAST(1.5 AS DECIMAL(10,2)), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#79ec780a8cab/ansi_off", - "reason": "SELECT sequence(CAST(1.5 AS DECIMAL(10,2)), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#7d2bdb1360c7/ansi_on", - "reason": "SELECT sequence(1, DATE'2024-02-29') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#7d2bdb1360c7/ansi_off", - "reason": "SELECT sequence(1, DATE'2024-02-29') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#824582274e20/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), X'01', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#824582274e20/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), X'01', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#88950751bef5/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), array(1, 2), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#88950751bef5/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), array(1, 2), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8935670449c8/ansi_on", - "reason": "SELECT sequence(TIMESTAMP'2024-02-29 12:34:56.123456', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8935670449c8/ansi_off", - "reason": "SELECT sequence(TIMESTAMP'2024-02-29 12:34:56.123456', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8da4b9e695df/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), 1L, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8da4b9e695df/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), 1L, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8f9c0db18869/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS DECIMAL(10,2))) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8f9c0db18869/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS DECIMAL(10,2))) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8fd1bb549361/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS FLOAT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#8fd1bb549361/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1.5 AS FLOAT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#958c36dac22c/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), 1.5D, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#958c36dac22c/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), 1.5D, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#9ed063d3215c/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), NULL) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#9ed063d3215c/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), NULL) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a10b76f32e61/ansi_on", - "reason": "SELECT sequence(1, TIMESTAMP_NTZ'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a10b76f32e61/ansi_off", - "reason": "SELECT sequence(1, TIMESTAMP_NTZ'2024-02-29 12:34:56.123456') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a2a4f0dd90ba/ansi_on", - "reason": "SELECT sequence(X'01', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a2a4f0dd90ba/ansi_off", - "reason": "SELECT sequence(X'01', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a62543ba6c53/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#a62543ba6c53/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#a7b9ea1535f9/ansi_on", - "reason": "SELECT sequence(1.5D, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a7b9ea1535f9/ansi_off", - "reason": "SELECT sequence(1.5D, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#a9045d74f03c/ansi_on", - "reason": "SELECT sequence(DATE'9999-12-31', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#a9045d74f03c/ansi_off", - "reason": "SELECT sequence(DATE'9999-12-31', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#ab4690e1b2b9/ansi_on", - "reason": "SELECT sequence(DATE'2024-02-29', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#ab4690e1b2b9/ansi_off", - "reason": "SELECT sequence(DATE'2024-02-29', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#ac3e4b3b333b/ansi_on", - "reason": "SELECT sequence(DATE'1582-10-10', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#ac3e4b3b333b/ansi_off", - "reason": "SELECT sequence(DATE'1582-10-10', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#b0ed212240a2/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), 'abc', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#b0ed212240a2/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), 'abc', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b2467da4cb98/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), '1') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b2467da4cb98/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), '1') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b2598b25c80d/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(NULL AS interval year to month)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#b2598b25c80d/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(NULL AS interval year to month)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#b3cf986ada1f/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 'abc') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b3cf986ada1f/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 'abc') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b9829d4862b6/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), X'01') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#b9829d4862b6/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), X'01') | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#bca72db9e8df/ansi_on", - "reason": "SELECT sequence(true, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#bca72db9e8df/ansi_off", - "reason": "SELECT sequence(true, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#c0b4339d1c29/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#c0b4339d1c29/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#c62d8cc43c51/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#c62d8cc43c51/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#ca96038b8e51/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS FLOAT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#ca96038b8e51/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1.5 AS FLOAT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#cce478cc4543/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), 1, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#cce478cc4543/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), 1, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#cdabb79b76eb/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), INTERVAL '1-2' YEAR TO MONTH) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#cdabb79b76eb/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), INTERVAL '1-2' YEAR TO MONTH) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#cf3e1121ffc4/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1.5D) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#cf3e1121ffc4/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1.5D) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d01d9144d407/ansi_on", - "reason": "SELECT sequence(TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d01d9144d407/ansi_off", - "reason": "SELECT sequence(TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', 5) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d12e4f46c718/ansi_on", - "reason": "SELECT sequence(CAST(1.5 AS FLOAT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d12e4f46c718/ansi_off", - "reason": "SELECT sequence(CAST(1.5 AS FLOAT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d22262ab5196/ansi_on", - "reason": "SELECT sequence(CAST(1 AS SMALLINT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d22262ab5196/ansi_off", - "reason": "SELECT sequence(CAST(1 AS SMALLINT), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d7b162a1fb9c/ansi_on", - "reason": "SELECT sequence(named_struct('a', 1, 'b', 'x'), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d7b162a1fb9c/ansi_off", - "reason": "SELECT sequence(named_struct('a', 1, 'b', 'x'), to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d83ec93f2b46/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1 AS SMALLINT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d83ec93f2b46/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1 AS SMALLINT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#d89bb544023a/ansi_on", - "reason": "SELECT sequence(TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#d89bb544023a/ansi_off", - "reason": "SELECT sequence(TIMESTAMP_NTZ'2024-02-29 12:34:56.123456', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#de1e47bcff4b/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1 AS TINYINT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#de1e47bcff4b/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(1 AS TINYINT)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#e7ff2267fb3c/ansi_on", - "reason": "SELECT sequence(TIMESTAMP'2024-02-29 12:34:56.123456', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#e7ff2267fb3c/ansi_off", - "reason": "SELECT sequence(TIMESTAMP'2024-02-29 12:34:56.123456', to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#ee0950e460ed/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1L) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#ee0950e460ed/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), 1L) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#f0e9903aac2f/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), array(1, 2)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#f0e9903aac2f/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), array(1, 2)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#f49336cfe797/ansi_on", - "reason": "SELECT sequence(1, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#f49336cfe797/ansi_off", - "reason": "SELECT sequence(1, to_date('2018-03-01'), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#f504495080e3/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(NULL AS interval month)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#f504495080e3/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), CAST(NULL AS interval month)) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps" - }, - { - "id": "sequence#fa3f9bfb1a24/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1 AS SMALLINT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#fa3f9bfb1a24/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), CAST(1 AS SMALLINT), interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#fe0f47d5ece7/ansi_on", - "reason": "SELECT sequence(to_date('2018-01-01'), true, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - }, - { - "id": "sequence#fe0f47d5ece7/ansi_off", - "reason": "SELECT sequence(to_date('2018-01-01'), true, interval 1 month) | KRISHIV_UNSUPPORTED_FEATURE: sequence over dates or timestamps where Spark has DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES" - } - ], - "format_version": 1, - "function": "sequence" -} diff --git a/tests/spark-golden/functions/run_oracle.py b/tests/spark-golden/functions/run_oracle.py new file mode 100644 index 000000000..964e6cc6c --- /dev/null +++ b/tests/spark-golden/functions/run_oracle.py @@ -0,0 +1,113 @@ +# SPDX-License-Identifier: Apache-2.0 +# ruff: noqa: S112, UP031, SIM115 +"""Run a golden .sql file against a real Spark and write the .out file. + +Usage (inside the apache/spark container, with spark-avro and spark-protobuf on --packages): + spark-submit --packages org.apache.spark:spark-avro_2.13:,org.apache.spark:spark-protobuf_2.13: (Scala 2.12 artifacts on Spark 3.5.x) \ + run_oracle.py + +Statements end with ';' at end of line. '--' lines are comments (copied to the output as-is +before the next query). An optional `.setup.py` is exec'd first with `spark` in scope. Each statement is executed in order on one session, so SET and +temporary views carry over. Output mirrors SQLQueryTestSuite: query, schema, output (via +cast-to-string rows) or the error (class, SQLSTATE, message parameters, message). +""" + +import os +import sys + +from pyspark.sql import SparkSession + + +def split_statements(text): + stmts, cur = [], [] + for line in text.splitlines(): + if not cur and (line.strip().startswith("--") or not line.strip()): + continue + cur.append(line) + if line.rstrip().endswith(";"): + stmts.append("\n".join(cur).rstrip()[:-1]) + cur = [] + if cur: + stmts.append("\n".join(cur)) + return stmts + + +def describe_error(e): + je = getattr(e, "java_exception", None) or getattr(e, "_origin", None) + if je is None: + return type(e).__name__ + "\nmessage: " + str(e).split("\n")[0] + out = [je.getClass().getName()] + cond = None + for getter in ("getCondition", "getErrorClass"): + try: + cond = getattr(je, getter)() + break + except Exception: # noqa: BLE001 + continue + if cond: + out.append("errorClass: " + str(cond)) + out.append("sqlState: " + str(je.getSqlState())) + params = je.getMessageParameters() + out.append( + "messageParameters: " + + str(dict(sorted((str(k), str(v)) for k, v in params.items()))) + ) + out.append("message: " + str(je.getMessage()).split("\n")[0]) + t, depth = je, 0 + while depth < 4: + c = t.getCause() + if c is None or c == t: + break + out.append( + "cause: %s: %s" + % (c.getClass().getName(), str(c.getMessage()).split("\n")[0]) + ) + t, depth = c, depth + 1 + return "\n".join(out) + + +def main(src, dst): + spark = ( + SparkSession.builder.appName("golden") + .config("spark.sql.session.timeZone", "UTC") + .getOrCreate() + ) + spark.sparkContext.setLogLevel("ERROR") + text = open(src, encoding="utf-8").read() + setup = os.path.splitext(src)[0] + ".setup.py" + if os.path.exists( + setup + ): # optional: builds views SQL cannot (e.g. malformed variants) + exec( # noqa: S102 + compile(open(setup, encoding="utf-8").read(), setup, "exec"), + {"spark": spark}, + ) + res = ["-- Generated by run_oracle.py against Spark " + spark.version, ""] + for q in split_statements(text): + res.append("-- !query") + res.append(q) + try: + df = spark.sql(q) + schema = df.schema.simpleString() + n = len(df.columns) + strs = df.toDF(*["c%d" % i for i in range(n)]).selectExpr( + *["cast(c%d as string)" % i for i in range(n)] + ) + rows = [ + "\t".join("NULL" if v is None else v for v in r) for r in strs.collect() + ] + res.append("-- !query schema") + res.append(schema) + res.append("-- !query output") + res.extend(str(r) for r in rows) + except Exception as e: # noqa: BLE001 + res.append("-- !query schema") + res.append("struct<>") + res.append("-- !query output") + res.append(describe_error(e)) + res.append("") + res.append("") + open(dst, "w", encoding="utf-8").write("\n".join(res)) + + +main(sys.argv[1], sys.argv[2]) diff --git a/tests/spark-golden/functions/sequence_xml/README.md b/tests/spark-golden/functions/sequence_xml/README.md new file mode 100644 index 000000000..7b1e4c7a6 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/README.md @@ -0,0 +1,112 @@ +# sequence(start, stop[, step]) over DATE / TIMESTAMP / TIMESTAMP_NTZ, and schema_of_xml(xml, options) goldens (SQL-6) + +Status target: `compatible` for every rule below. The "Quirks" list is Spark behaviour that looks like a bug (recorded, +not endorsed; `incompatible` candidates, opt-in via `krishiv.expr..allowIncompatible`). + +Layout: `inputs/.sql` (`;`-terminated statements, one session, so SET and views carry over), +`results/spark-/.sql.out` (output of a real run), `run.sh [name]`. The runner is `../run_oracle.py`. +Every expected value was produced by executing Spark; none is transcribed. Hand-written expectations: none. + +| Case file | Queries | Covers | +|---|---|---| +| `sequence_dates` | 84 | DATE: calendar-style `interval 1 month`, ANSI year-month and day-time steps, default step, descending, step 0, wrong direction, NULL, month-end clamping, type errors, ANSI off | +| `sequence_timestamps` | 83 | TIMESTAMP and TIMESTAMP_NTZ in UTC: same matrix, sub-second steps, default step, ANSI off | +| `sequence_tz` | 60 | `America/Los_Angeles` across 2018-03-11 (spring forward) and 2018-11-04 (fall back), step `1 day` vs `24 hours`; NTZ is zone independent; `Australia/Lord_Howe`, `Asia/Kolkata` | +| `sequence_calendar` | 78 | true CALENDAR interval steps (`make_interval`, `cast('..' as interval)`, `spark.sql.legacy.interval.enabled=true` literals), in UTC and in the DST zone | +| `sequence_errors` | 62 | exact error classes/messages, maximum array length, column inputs, CASE/IF/COALESCE/WHERE conditional evaluation | +| `schema_of_xml` | 204 | options, nested/repeated/attributes-only/empty/mixed/invalid XML, types, namespaces, ANSI off, time zone, conditional evaluation | + +## How the .out files were made + +`apache/spark:` container `krishiv-s7sql456-oracle-` (`--rm`, removed on exit), `spark-submit ../run_oracle.py`, +session time zone UTC unless the file `SET`s it, ANSI default on (files also `SET spark.sql.ansi.enabled=false` for a +block). Runs: **4.2.0 and 4.3.0**. 3.5.7, 4.0.0 and 4.1.0 were NOT run (`unverified-by-run`; `schema_of_xml`/`from_xml` +are new in 4.0, so 3.5 is expected `UNRESOLVED_ROUTINE`). The `.out` files are root-owned (written from the container). +Source read at tags `v4.2.0` and `v4.3.0` via raw.githubusercontent.com; the fetch tool truncated the large files and gave no +line numbers, so each rule cites file + declaration (line numbers `unavailable`). + +Sources: `sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala` +(`Sequence`, `InternalSequenceBase`, `IntegralSequenceImpl`, `TemporalSequenceImpl`, `DurationSequenceImpl`, +`PeriodSequenceImpl`, `getSequenceLength`), `.../catalyst/xml/XmlOptions.scala`, `.../catalyst/xml/XmlInferSchema.scala`, +`.../expressions/xml/xmlExpressions.scala` (`SchemaOfXml`). + +## sequence rules (identical on 4.2.0 and 4.3.0) + +| Rule | Source | Case file | +|---|---|---| +| Result type `array` for DATE bounds, `array` for TIMESTAMP, TIMESTAMP_NTZ gives NTZ array; mixed DATE and TIMESTAMP/NTZ bounds coerce to a timestamp array (`2018-01-01 00:00:00`...) | run | dates, timestamps | +| Arity 2 or 3, else `WRONG_NUM_ARGS.WITHOUT_SUGGESTION` (42605, `expectedNum` `[2, 3]`) | run | dates, errors | +| Step types accepted for temporal bounds: CALENDAR interval, INTERVAL YEAR TO MONTH (any `year`/`month` field), INTERVAL DAY TO SECOND (any fields). An integral, string, NULL-literal (untyped) or boolean step => `DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES` (42K09); a typed NULL interval (`cast(NULL as interval day)`) => result NULL | `Sequence.checkInputDataTypes`; run | dates, timestamps | +| Any NULL start, stop or (typed) step => NULL | run | dates, timestamps | +| Default step (omitted): `+1 day` if start <= stop, `-1 day` otherwise (`TemporalSequenceImpl` default `CalendarInterval(0,1,0)`; usage text "1 day and -1 day"). So `sequence(ts, ts + 3s)` is a one-element array and `sequence(date, earlier date)` counts down by day | run | dates, timestamps | +| A step is split into (months, days, microseconds). YEAR TO MONTH step => (n, 0, 0); DAY TO SECOND step => days = whole days of the duration, micros = remainder (so `interval 24 hours` == `interval 1 day`, see quirk 1); CALENDAR => its own three fields | `splitStep` in `DurationSequenceImpl`/`PeriodSequenceImpl`/`TemporalSequenceImpl` | tz, calendar | +| Element i is `start + i*step` evaluated from the START each time (not accumulated), so Jan 31 + 1 month: `Jan 31, Feb 28, Mar 31, Apr 30, May 31, Jun 30`; leap years: `2020-01-31`... `Feb 29`; `2020-02-29 + 1 year` => `2021-02-28 ... 2024-02-29` | `addInterval`; run | dates, timestamps | +| Inclusive of stop when it lands exactly; stops before overshoot; start == stop => `[start]` for any non-zero step | run | dates | +| DATE bounds: stepping is done on DATE (days); the step must have a non-zero month or day part, else `_LEGACY_ERROR_TEMP_3242` (`SparkIllegalArgumentException`, SQLSTATE none) message `sequence step must be an interval of day granularity if start and end values are dates`, where `` is `day to second`, `year to month` or `interval` (CALENDAR, and under legacy.interval literals). This fires for step 0 and for sub-day steps (`interval 12 hours`, `1 microsecond`, `make_interval(0,0,0,0,24)`) but a day plus remainder (`1 day 12 hours`, `1 day 1 microsecond`) is accepted and truncates to days: `1 day 12 hours` => `Jan 1, Jan 2, Jan 4` | `InternalSequenceBase.eval` (`scale == MICROS_PER_DAY && stepMonths == 0 && stepDays == 0`); run | dates, calendar, errors | +| TIMESTAMP/NTZ bounds with step 0 or wrong-direction step: `java.lang.IllegalArgumentException` `requirement failed: Illegal sequence boundaries: to by ` (no error class). `` is the raw step: months as a bare integer for YM steps (`by -1`), micros for DT steps (`by 3600000000`), `by 1 months` for CALENDAR steps, `by 0` for a zero CALENDAR step. DATE wrong direction: `Illegal sequence boundaries: 17532 to 17536 by -1` (epoch days) for a day step but micros for a month step. In a column / non-constant-folded path the same error is `SparkIllegalArgumentException _LEGACY_ERROR_TEMP_3243` with params `start`,`stop`,`step`, message `Illegal sequence boundaries: ...` (no `requirement failed:` prefix) | `getSequenceLength` `require`; generated code `_LEGACY_ERROR_TEMP_3243`; run | errors (view `sq`), timestamps, dates | +| Maximum array length: `SparkRuntimeException` `COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER` SQLSTATE 54000, params `functionName` `` `sequence` ``, `maxRoundedArrayLength` `2147483632`, `numberOfElements` (exact count, computed in BigInt on overflow), `parameter` `` `count` ``. Applies to integral (`sequence(1, 2147483647)` => 2147483647 elements) and temporal (`1 microsecond` over a year => `31449600000001`). 2147483632 elements is not rejected up front (a JVM heap OOM in the 1 GB oracle, so not recorded) | `Sequence.sequenceLength` / `MAX_ROUNDED_ARRAY_LENGTH`; run | errors | +| `size(sequence(date 0001-01-01, 9999-12-31, 1 day))` = 3652059 | run | errors | +| Session time zone only matters for TIMESTAMP (and DATE->micros conversions): months/days are added in local wall-clock time via the session zone, remainder micros are added as elapsed time. Spring forward (LA 2018-03-11): `1 day` and `24 hours` from `03-10 00:00` give `03-10, 03-11, 03-12, 03-13 00:00`; from `03-10 02:30` `1 day` gives `03-11 03:30` (gap resolved forward) then `03-12 02:30`; `sequence(ts 03-11 02:30, 03-12 02:30, 1 day)` is `[03-11 03:30]` (the nonexistent start 02:30 is already shifted to 03:30, so the next element 03-12 03:30 is past stop 03-12 02:30). `1 hour` over the gap skips `02:00` (`00,01,03,04,05`). Fall back (2018-11-04): `1 hour` repeats `01:00` (two equal elements); `1 day` stays on midnight / the same wall time | `timestampAddInterval`; run | tz | +| TIMESTAMP_NTZ ignores the session zone (`1 hour` across the LA gap gives `00,01,02,03,04,05`) | `timestampNTZAddInterval`; run | tz | +| CALENDAR interval `24 hours` is real elapsed time, unlike the ANSI DT interval: LA `make_interval(0,0,0,0,24)` from `03-10 00:00` gives `03-10 00:00, 03-11 00:00, 03-12 01:00`, and across fall back `11-03 00:00, 11-04 00:00, 11-04 23:00, 11-05 23:00`. `make_interval(0,0,0,1)` (1 day) stays on wall-clock midnight | run | calendar | +| `interval 1 month 2 days` (mixed fields) is a parse error `_LEGACY_ERROR_TEMP_0029` (ParseException, params `literal`) with ANSI on **and off**; it is a CALENDAR interval only with `spark.sql.legacy.interval.enabled=true`. Calendar steps are otherwise built with `make_interval` or `cast('1 month 2 days' as interval)`. Month+day step: `(2018-01-01, 2018-04-05, 1 month 2 days)` => `01-01, 02-03, 03-05` (start + i*(1 month, 2 days) each from start); negative day part allowed (`make_interval(0,1,0,-2)` => `01-01, 01-30, 02-25`): the direction check is on the combined step | `AstBuilder` interval literal; run | calendar, errors | +| `interval '1' year to month` etc. with a malformed string literal is `INVALID_INTERVAL_FORMAT.UNMATCHED_FORMAT_STRING` (22006); `interval 9999999999 days` overflows the interval literal: `INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION` (22006) | run | dates, errors | +| ANSI on/off: no difference in results or error classes for any numeric/interval/type-error case, EXCEPT that string bounds are coerced only with ANSI on: `sequence(date, '2018-01-05', interval 1 day)` works on (result is dates) and raises `SEQUENCE_WRONG_INPUT_TYPES` off (quirk 4) | run | dates | +| Conditional evaluation: `CASE`/`IF`/`COALESCE` and `WHERE id = 1 AND size(sequence(..))` do not raise on unselected rows (view `sq`, a step-0 row and a wrong-direction row); but `WHERE id <> 2 AND size(sequence(a, b, s)) = 3` still evaluates the row with the wrong direction (id 3) and raises (not a conditional guard). `CASE WHEN s > interval 0 month THEN sequence(...)` with a NULL-bounds row gives NULL | run | errors | + +## schema_of_xml rules + +`schema_of_xml(xml_literal [, map(...)])` returns a STRING (a DDL-like `STRUCT<...>` text, uppercase types, backticks around +names needing quotes, fields sorted by name in code-point order: `_VALUE` < `_attr` < lower-case names). Equal on 4.2.0 and +4.3.0 except the single difference noted. + +| Rule | Source | Case file | +|---|---|---| +| Issue example: `schema_of_xml('

13

', map('excludeAttribute','true'))` => `STRUCT>`; without options => `STRUCT>>` (the first `a` has an attribute so both elements are structs; the second has `_attr` only in the schema, not a value) | run | schema_of_xml | +| Input must be a foldable STRING: NULL (typed or not) => `DATATYPE_MISMATCH.UNEXPECTED_NULL` (42K09, param `exprName` `xml`); non-STRING (INT, BINARY) => `DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE`; a column => `DATATYPE_MISMATCH.NON_FOLDABLE_INPUT`; arity 1 or 2 (`expectedNum [1, 2]`) | `SchemaOfXml.checkInputDataTypes`; run | schema_of_xml | +| Options must be a literal `map()` of string => string: NULL/`named_struct`/string => `INVALID_OPTIONS.NON_MAP_FUNCTION` (42K06); `map()` with no entries, a non-STRING value, or a NULL value => `INVALID_OPTIONS.NON_STRING_TYPE` (42K06); non-foldable keys/values (a column) => `INTERNAL_ERROR` `Cannot evaluate expression` (quirk 6) | run | schema_of_xml | +| Option names are case-insensitive; unknown options are ignored | `XmlOptions` (CaseInsensitiveMap); run | schema_of_xml | +| `excludeAttribute` (default false, `getBool`: only true/false, else `_LEGACY_ERROR_TEMP_2147` `excludeAttribute flag can be true or false.`): drops all attribute fields; element-with-only-attributes then has `STRUCT<>`; text+attributes collapses to `_VALUE` only or the primitive | `XmlOptions`; `XmlInferSchema`; run | schema_of_xml | +| `attributePrefix` default `_` (any string, incl. empty `''` => bare names, and `@` => `` `@attr` `` quoted); `valueTag` default `_VALUE`, `''` => `IllegalArgumentException` `requirement failed: 'valueTag' option should not be empty string.`; the two are not forced to differ in this path (`attributePrefix=''` with `valueTag='attr'` gives two `attr` fields) | `XmlOptions` | schema_of_xml | +| `valueTag` field exists only when an element has text AND attributes or child elements; text interleaved with children (`textmore`) makes it `ARRAY` (pieces) | `XmlInferSchema.inferObject` | schema_of_xml | +| Repeated element names => `ARRAY`; element types merged (`11.5` => `ARRAY`; `1` + `x` => `ARRAY`; struct+struct merge fields; primitive+struct => `ARRAY`) | `compatibleType` | schema_of_xml | +| Inference order Long(BIGINT) -> Decimal (only `prefersDecimal=true`) -> Double -> Boolean (`true`/`TRUE`) -> Date -> Timestamp -> String. `+5`, `00123` are BIGINT; `1e3`, `-0.0`, 20-digit integers are DOUBLE; `NaN`/`Infinity` are STRING; `prefersDecimal=true`: `1.5` => `DECIMAL(2,1)`, `99999999999999999999` => `DECIMAL(20,0)`, beyond 38 digits => DOUBLE, mixed `1.5` + `2` => `DECIMAL(21,1)`; `prefersDecimal='maybe'` => `IllegalArgumentException: For input string: "maybe"` (uses `toBoolean`, not `getBool`) | `inferFrom`, `compatibleType`; run | schema_of_xml | +| `inferSchema=false` => every leaf STRING (`inferSchema='maybe'` => `_LEGACY_ERROR_TEMP_2147`) | `inferFrom` | schema_of_xml | +| `timestampFormat`/`timestampNTZFormat`/`dateFormat`: `2020-01-02T03:04:05` is TIMESTAMP (never NTZ here, even with `timestampNTZFormat`); `dateFormat='yyyy/MM/dd'` makes `2020-01-02` TIMESTAMP and `2020/01/02` DATE. Session time zone has no effect on the printed schema | run | schema_of_xml | +| `ignoreSurroundingSpaces` default true (`' 1 '` => BIGINT); false => STRING | `XmlOptions` | schema_of_xml | +| `ignoreNamespace=true` strips prefixes from element/attribute names (`ns:a` => `a`, merging with `a` into `ARRAY<..>`); default keeps them as `` `ns:a` `` and exposes the declaration as `` `_xmlns:ns`: STRING``. With `ignoreNamespace=true` the declaration attribute is still present but named `_ns`; a default `xmlns="..."` stays `_xmlns` | run | schema_of_xml | +| `samplingRatio`: parsed as a double, must be `> 0` (`requirement failed: samplingRatio (0.0) should be greater than 0`); values > 1 accepted; non-numeric => `NumberFormatException`. No effect on a single literal | `XmlOptions` | schema_of_xml | +| `rowTag` is ignored by `schema_of_xml` (the whole document root is the row; root element name never appears) | run | schema_of_xml | +| Parse failures: default `mode=PERMISSIVE` returns `STRUCT<_corrupt_record: STRING>` (session `columnNameOfCorruptRecord`, `columnNameOfCorruptRecord` option not honoured: stays `_corrupt_record`), covers `''`, `' '`, `not xml`, unclosed or mismatched tags, bare `<`, unknown entity, `a=1` unquoted, duplicate attribute. `mode=FAILFAST` => `SparkException` `MALFORMED_RECORD_IN_PARSING.WITHOUT_SUGGESTION` (22023, `badRecord` `_corrupt_record`, `failFastMode` FAILFAST) with a cause; `DROPMALFORMED` => `PARSE_MODE_UNSUPPORTED` (42601, "Acceptable modes are PERMISSIVE and FAILFAST"); an unknown mode string behaves as PERMISSIVE. Trailing content after the first root element is ignored (`

`, `garbage`); the XML declaration, comments and CDATA are accepted | `handleXmlErrorsByParseMode`; run | schema_of_xml | +| `timeZone` option validated: `Not/AZone` => `INVALID_TIMEZONE` (22009); `locale=de-DE` with prefersDecimal still parses `1,5` as `DECIMAL(2,1)` | run | schema_of_xml | +| The schema is directly usable: `from_xml(x, schema_of_xml(x))` => `{[{1, 2}, {3, null}]}` and with `excludeAttribute` on both `{[1, 3]}` | run | schema_of_xml | +| ANSI on/off and conditional evaluation (CASE/IF/COALESCE/WHERE with AND false around a bad `schema_of_xml('

')`): no difference, no raise | run | schema_of_xml | + +## Per-version differences + +- `sequence`: 4.2.0 and 4.3.0 outputs are byte identical apart from the header line. +- `schema_of_xml`: exactly one difference, in `nullValue` handling. `schema_of_xml('

x1

', map('nullValue','x'))` + is `STRUCT>` on 4.2.0 and `STRUCT>` on 4.3.0; likewise + `NULL1` with `nullValue='NULL'`. So 4.3.0 treats a value equal to `nullValue` as null during inference. + Krishiv targeting 4.2 should keep 4.2 behaviour behind the version key. +- 3.5.x / 4.0.x / 4.1.x: not run (`unverified-by-run`). + +## Quirks to decide (Spark behaviour that looks like a bug) + +1. `interval 24 hours` (DAY TO SECOND) == `interval 1 day` for TIMESTAMP bounds (whole days are split out), so it does not + mean 24 elapsed hours across DST, while the equivalent CALENDAR `make_interval(0,0,0,0,24)` does. +2. The wrong-direction / zero-step error is a bare `java.lang.IllegalArgumentException` (`requirement failed:` prefix, no + error class) in the interpreted path but `_LEGACY_ERROR_TEMP_3243` in the generated/column path; the step is printed raw. +3. `_LEGACY_ERROR_TEMP_3242` for a DATE sub-day or zero step names the interval type but has no SQLSTATE. +4. String bounds coerce to dates only under ANSI on; no coercion under ANSI off. +5. `interval 1 month 2 days` is a parse error even with ANSI off (only the legacy flag allows it). +6. `schema_of_xml` with option map values from a column dies with `INTERNAL_ERROR Cannot evaluate expression`. +7. `valueTag`/`attributePrefix` can collide (`attr` + `attr` duplicate field names printed). +8. `timestampNTZFormat` never makes `schema_of_xml` infer `TIMESTAMP_NTZ`; `dateFormat` of another shape makes ISO dates TIMESTAMP. +9. `columnNameOfCorruptRecord` option is not honoured by `schema_of_xml` (always `_corrupt_record`). + +## Not covered / open + +- `sequence(0, 2147483631)` (largest permitted integral) hit a JVM heap OOM in the default container and was dropped. +- 3.5.7/4.0.0/4.1.0 not run; source line numbers not obtained (fetch tool returned no numbering). +- `schema_of_xml` over multiple rows / `samplingRatio` on files is a reader concern (`spark.read.xml`), out of scope here. diff --git a/tests/spark-golden/functions/sequence_xml/inputs/schema_of_xml.sql b/tests/spark-golden/functions/sequence_xml/inputs/schema_of_xml.sql new file mode 100644 index 000000000..25d4b8a9f --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/schema_of_xml.sql @@ -0,0 +1,215 @@ +-- schema_of_xml(xml [, options]): inference over a single literal; options excludeAttribute, attributePrefix, valueTag, ... +SET spark.sql.session.timeZone=UTC; +SELECT schema_of_xml('

13

', map('excludeAttribute','true')); +SELECT schema_of_xml('

13

'); +SELECT schema_of_xml('

13

', map('excludeAttribute','false')); +SELECT schema_of_xml('

13

', map()); +SELECT schema_of_xml('

13

', map('attributePrefix','at_')); +SELECT schema_of_xml('

13

', map('attributePrefix','')); +SELECT schema_of_xml('

13

', map('valueTag','v')); +SELECT schema_of_xml('

13

', map('valueTag','v', 'attributePrefix','@')); +SELECT schema_of_xml('

13

', map('valueTag','attr')); +SELECT schema_of_xml('

13

', map('attributePrefix','', 'valueTag','attr')); +SELECT schema_of_xml('

13

', map('valueTag','')); +SELECT schema_of_xml('

13

', map('attributePrefix','a')); +SELECT schema_of_xml('

13

', map('excludeAttribute','true', 'valueTag','v')); +SELECT schema_of_xml('

13

', map('excludeAttribute','yes')); +SELECT schema_of_xml('

13

', map('excludeattribute','true')); +SELECT schema_of_xml('

13

', map('EXCLUDEATTRIBUTE','TRUE')); +SELECT schema_of_xml('

13

', map('unknownOption','x')); +SELECT schema_of_xml('

13

', map('excludeAttribute', NULL)); +SELECT schema_of_xml('

13

', NULL); +SELECT schema_of_xml(NULL); +SELECT schema_of_xml(NULL, map('excludeAttribute','true')); +SELECT schema_of_xml(cast(NULL as string)); +SELECT schema_of_xml('

13

', map('excludeAttribute', true)); +SELECT schema_of_xml('

13

', map('excludeAttribute', 1)); +SELECT schema_of_xml('

13

', named_struct('excludeAttribute','true')); +SELECT schema_of_xml('

13

', 'excludeAttribute'); +SELECT schema_of_xml('

13

', map('excludeAttribute', 'true'), 1); +SELECT schema_of_xml(); +SELECT schema_of_xml(1); +SELECT schema_of_xml(x'3c613e313c2f613e'); +SELECT schema_of_xml(concat('

', '1', '

')); +SELECT typeof(schema_of_xml('

1

')); +SELECT schema_of_xml('

1

') AS s; +SELECT schema_of_xml('

1

') FROM range(3); +SELECT schema_of_xml(col) FROM VALUES ('

1

') AS t(col); +SELECT schema_of_xml('

1

', map(k, 'true')) FROM VALUES ('excludeAttribute') AS t(k); +SELECT schema_of_xml('

1

', map('excludeAttribute', v)) FROM VALUES ('true') AS t(v); +-- nested, repeated, attributes only, empty, mixed text +SELECT schema_of_xml('

1x

'); +SELECT schema_of_xml('

12

'); +SELECT schema_of_xml('

12

'); +SELECT schema_of_xml('

123

'); +SELECT schema_of_xml('

1x2

'); +SELECT schema_of_xml('

1x

'); +SELECT schema_of_xml('

11.5

'); +SELECT schema_of_xml('

1true

'); +SELECT schema_of_xml('

12

'); +SELECT schema_of_xml('

21

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

', map('excludeAttribute','true')); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

', map('excludeAttribute','true')); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

', map('excludeAttribute','true')); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

', map('excludeAttribute','true')); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

', map('excludeAttribute','true')); +SELECT schema_of_xml('

text

'); +SELECT schema_of_xml('

text

', map('excludeAttribute','true')); +SELECT schema_of_xml('

text

', map('valueTag','val')); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

text

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

text1

'); +SELECT schema_of_xml('

text1more

'); +SELECT schema_of_xml('

text1more

', map('valueTag','v')); +SELECT schema_of_xml('

112

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','true')); +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','false')); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

2'); +SELECT schema_of_xml('

<1>

'); +SELECT schema_of_xml('

&

'); +SELECT schema_of_xml('

A

'); +SELECT schema_of_xml('

<é>1

'); +SELECT schema_of_xml('

123

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

xy

'); +SELECT schema_of_xml('

xy

', map('excludeAttribute','true')); +SELECT schema_of_xml('

12

'); +SELECT schema_of_xml('

v

', map('attributePrefix','_', 'valueTag','#text')); +-- types +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

'); +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','false')); +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','true')); +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('prefersDecimal','true')); +SELECT schema_of_xml('

121474836481.5true

', map('prefersDecimal','false')); +SELECT schema_of_xml('

1.52

', map('prefersDecimal','true')); +SELECT schema_of_xml('

1.5x

', map('prefersDecimal','true')); +SELECT schema_of_xml('

1e3

'); +SELECT schema_of_xml('

1e3

', map('prefersDecimal','true')); +SELECT schema_of_xml('

99999999999999999999

'); +SELECT schema_of_xml('

99999999999999999999

', map('prefersDecimal','true')); +SELECT schema_of_xml('

99999999999999999999999999999999999999999

', map('prefersDecimal','true')); +SELECT schema_of_xml('

0.1234567890123456789012345678901234567890

', map('prefersDecimal','true')); +SELECT schema_of_xml('

NaNInfinity-Infinity

'); +SELECT schema_of_xml('

-0.0

'); +SELECT schema_of_xml('

00123

'); +SELECT schema_of_xml('

+5

'); +SELECT schema_of_xml('

TRUETrue

'); +SELECT schema_of_xml('

2020-01-02 03:04:05

'); +SELECT schema_of_xml('

2020-01-02T03:04:05Z

'); +SELECT schema_of_xml('

2020-01-02T03:04:05+01:00

'); +SELECT schema_of_xml('

2020-01-02T03:04:05.123456

'); +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss')); +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')); +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss', 'timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')); +SELECT schema_of_xml('

2020-01-02

', map('dateFormat','yyyy/MM/dd')); +SELECT schema_of_xml('

2020/01/02

', map('dateFormat','yyyy/MM/dd')); +SELECT schema_of_xml('

2020-01-02T03:04:052020-01-02T03:04:05Z

'); +SELECT schema_of_xml('

2020-01-022020-01-02T03:04:05

'); +SELECT schema_of_xml('

12020-01-02

'); +SELECT schema_of_xml('

12147483648

'); +SELECT schema_of_xml('

11.5

', map('prefersDecimal','true')); +SELECT schema_of_xml('

', map('nullValue','x')); +SELECT schema_of_xml('

x1

', map('nullValue','x')); +SELECT schema_of_xml('

NULL

', map('nullValue','NULL')); +SELECT schema_of_xml('

NULL1

', map('nullValue','NULL')); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

1

'); +-- samplingRatio (single row: no effect on a literal) +SELECT schema_of_xml('

1

', map('samplingRatio','0.5')); +SELECT schema_of_xml('

1

', map('samplingRatio','1.0')); +SELECT schema_of_xml('

1

', map('samplingRatio','0')); +SELECT schema_of_xml('

1

', map('samplingRatio','-1')); +SELECT schema_of_xml('

1

', map('samplingRatio','2')); +SELECT schema_of_xml('

1

', map('samplingRatio','abc')); +-- namespaces +SELECT schema_of_xml('12'); +SELECT schema_of_xml('12', map('ignoreNamespace','true')); +SELECT schema_of_xml('12', map('ignoreNamespace','false')); +SELECT schema_of_xml('

12

'); +SELECT schema_of_xml('

12

', map('ignoreNamespace','true')); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

', map('ignoreNamespace','true')); +SELECT schema_of_xml('

123

', map('ignoreNamespace','true')); +-- other options +SELECT schema_of_xml('

1

', map('rowTag','p')); +SELECT schema_of_xml('

12

', map('rowTag','q')); +SELECT schema_of_xml('

1

', map('rowTag','zzz')); +SELECT schema_of_xml('

1

', map('mode','FAILFAST')); +SELECT schema_of_xml('

1

', map('mode','PERMISSIVE')); +SELECT schema_of_xml('

1

', map('mode','DROPMALFORMED')); +SELECT schema_of_xml('

1

', map('mode','bogus')); +SELECT schema_of_xml('

1

', map('columnNameOfCorruptRecord','_bad')); +SELECT schema_of_xml('

1

', map('wildcardColName','w')); +SELECT schema_of_xml('

1

', map('charset','UTF-8')); +SELECT schema_of_xml('

1

', map('encoding','UTF-8')); +SELECT schema_of_xml('

1

', map('declaration','x')); +SELECT schema_of_xml('

1

', map('locale','de-DE')); +SELECT schema_of_xml('

1,5

', map('locale','de-DE', 'prefersDecimal','true')); +SELECT schema_of_xml('

1

', map('multiLine','true')); +SELECT schema_of_xml('

1

', map('inferSchema','maybe')); +SELECT schema_of_xml('

1

', map('prefersDecimal','maybe')); +SELECT schema_of_xml('

1

', map('timeZone','America/Los_Angeles')); +SELECT schema_of_xml('

1

', map('timeZone','Not/AZone')); +SELECT schema_of_xml('

1

', map('validateName','false')); +SELECT schema_of_xml('

1

', map('samplingRatio','0.5', 'attributePrefix','_', 'valueTag','_v', 'excludeAttribute','true', 'ignoreNamespace','true', 'prefersDecimal','true', 'inferSchema','true')); +-- invalid XML +SELECT schema_of_xml(''); +SELECT schema_of_xml(' '); +SELECT schema_of_xml('not xml'); +SELECT schema_of_xml('

1'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml('

&unknown;

'); +SELECT schema_of_xml('<'); +SELECT schema_of_xml('

1

garbage'); +SELECT schema_of_xml('

', map('mode','FAILFAST')); +SELECT schema_of_xml('

', map('mode','PERMISSIVE')); +SELECT schema_of_xml('

', map('mode','DROPMALFORMED')); +SELECT schema_of_xml('

', map('excludeAttribute','true')); +SELECT schema_of_xml('

1

'); +SELECT schema_of_xml('

1

'); +-- ANSI off: same queries +SET spark.sql.ansi.enabled=false; +SELECT schema_of_xml('

13

', map('excludeAttribute','true')); +SELECT schema_of_xml('

13

'); +SELECT schema_of_xml('

'); +SELECT schema_of_xml(NULL); +SET spark.sql.ansi.enabled=true; +-- time zone has no effect on the schema +SET spark.sql.session.timeZone=America/Los_Angeles; +SELECT schema_of_xml('

2020-01-02T03:04:05

'); +SELECT schema_of_xml('

2020-01-02T03:04:05Z

'); +SET spark.sql.session.timeZone=UTC; +-- schema usable by from_xml +SELECT from_xml('

13

', schema_of_xml('

13

')); +SELECT from_xml('

13

', schema_of_xml('

13

', map('excludeAttribute','true')), map('excludeAttribute','true')); +-- conditional evaluation +SELECT CASE WHEN 1 = 2 THEN schema_of_xml('

') ELSE 'ok' END; +SELECT IF(false, schema_of_xml('

'), 'ok'); +SELECT COALESCE('ok', schema_of_xml('

')); +SELECT * FROM range(2) WHERE id = 5 AND schema_of_xml('

') = 'x'; diff --git a/tests/spark-golden/functions/sequence_xml/inputs/sequence_calendar.sql b/tests/spark-golden/functions/sequence_xml/inputs/sequence_calendar.sql new file mode 100644 index 000000000..01a80e02f --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/sequence_calendar.sql @@ -0,0 +1,82 @@ +-- sequence with a CALENDAR interval step (make_interval / cast from string / legacy interval literal) +SET spark.sql.session.timeZone=UTC; +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 24)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 12)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1, 12)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 0, 0, 1)); +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), make_interval(0, 1)); +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), make_interval(0, -1)); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), make_interval(0, 1)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, -1)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 0)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval()); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1, 0, -2)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), cast('1 month' as interval)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), cast('1 month 2 days' as interval)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast('1 day' as interval)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval)); +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1))); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, 1)); +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', make_interval(0, 1)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', make_interval(0, 0, 0, 0, 6)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', make_interval(0, 0, 0, 0, 0, 0, 0.5)); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1)); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, 1)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, -1)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval()); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', make_interval(0, 1, 0, -2)); +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1, 0, 2)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 1, 0, 2)); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval(0, 1)); +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', make_interval(0, 1)); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval()); +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', make_interval(0, 1)); +-- DST zone +SET spark.sql.session.timeZone=America/Los_Angeles; +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 0, 24)); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 1)); +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', make_interval(0, 1)); +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 0, 24)); +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', make_interval(0, 0, 0, 1)); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 12)); +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', make_interval(0, 0, 0, -1)); +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)); +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), make_interval(0, 0, 0, 1)); +SET spark.sql.session.timeZone=UTC; +-- ANSI off +SET spark.sql.ansi.enabled=false; +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month); +SELECT typeof(interval 1 month 2 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours); +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)); +SET spark.sql.ansi.enabled=true; +-- legacy interval literals +SET spark.sql.legacy.interval.enabled=true; +SELECT typeof(interval 1 month 2 days); +SELECT typeof(interval 1 month); +SELECT typeof(interval 1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month); +SET spark.sql.legacy.interval.enabled=false; diff --git a/tests/spark-golden/functions/sequence_xml/inputs/sequence_dates.sql b/tests/spark-golden/functions/sequence_xml/inputs/sequence_dates.sql new file mode 100644 index 000000000..d02c46098 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/sequence_dates.sql @@ -0,0 +1,86 @@ +-- sequence over DATE: calendar-interval, year-month, day-time steps, default step, directions +SET spark.sql.session.timeZone=UTC; +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month); +SELECT sequence(to_date('2018-01-01'), to_date('2020-01-01'), interval '1' year); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1 0' day to hour); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '2 0:0:0' day to second); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 24 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 12 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 1 hour); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 month 2 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')); +SELECT sequence(to_date('2018-01-05'), to_date('2018-01-01')); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01')); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 1 month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval -1 month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' day); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 0 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 0 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0); +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month); +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval '1' month); +SELECT sequence(to_date('2020-01-31'), to_date('2020-05-31'), interval 1 month); +SELECT sequence(to_date('2020-02-29'), to_date('2024-03-01'), interval '1' year); +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), interval -1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), NULL); +SELECT sequence(NULL, to_date('2018-01-05'), interval 1 day); +SELECT sequence(to_date('2018-01-01'), NULL, interval 1 day); +SELECT sequence(cast(NULL as date), cast(NULL as date)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval day)); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval month)); +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month)); +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month)); +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'))); +SELECT sequence(to_date('0001-01-01'), to_date('0001-03-01'), interval 1 month); +SELECT sequence(to_date('9999-11-01'), to_date('9999-12-31'), interval 1 month); +SELECT sequence(to_date('1582-10-01'), to_date('1582-10-20'), interval 5 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 12 hours); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 microsecond); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 1 microsecond); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 86400000000 microseconds); +SELECT size(sequence(to_date('2000-01-01'), to_date('2000-12-31'))); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 1); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1 day'); +SELECT sequence(to_date('2018-01-01'), 5, interval 1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1); +SELECT sequence(to_date('2018-01-01')); +SELECT sequence(date '2018-01-01', timestamp '2018-01-03 00:00:00', interval 1 day); +SELECT sequence(date '2018-01-01', timestamp_ntz '2018-01-03 00:00:00', interval 1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' year to month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '10' day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 week); +SELECT sequence(to_date('2018-01-01'), to_date('2018-02-01'), interval 1 week); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month, 1); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 quarter); +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 3 months); +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 1 year 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2020-12-01'), interval 1 year 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1 1' year to month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1-1' year to month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 0 months 1 day); +-- ANSI off: same queries must not change; spot check +SET spark.sql.ansi.enabled=false; +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month); +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1'); +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day); +SET spark.sql.ansi.enabled=true; +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day); diff --git a/tests/spark-golden/functions/sequence_xml/inputs/sequence_errors.sql b/tests/spark-golden/functions/sequence_xml/inputs/sequence_errors.sql new file mode 100644 index 000000000..7707ecdc9 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/sequence_errors.sql @@ -0,0 +1,75 @@ +-- sequence: errors, maximum array length, conditional evaluation, columns +SET spark.sql.session.timeZone=UTC; +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '0' day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour); +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 month 0 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 month -2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', interval 1 month -2 days); +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month 2 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month -2 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month 0 days); +SELECT sequence(to_date('2018-03-02'), to_date('2018-01-01'), interval -1 month -2 days); +-- array length limit (Spark: MAX_ROUNDED_ARRAY_LENGTH = 2147483632) +SELECT size(sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond); +SELECT size(sequence(to_date('0001-01-01'), to_date('9999-12-31'), interval 1 day)); +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 microsecond); +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 millisecond); +SELECT size(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:05', interval 1 microsecond)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-02-01 00:00:00', interval 1 microsecond); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-12-31 00:00:00', interval 1 microsecond); +SELECT sequence(1, 2147483647); +SELECT sequence(1L, 2147483648L); +SELECT sequence(1, 2147483633); +SELECT sequence(-2147483648, 2147483647); +SELECT sequence(-2147483648, 2147483647, 2147483647); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 106751991 days); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 9999999999 days); +-- column inputs and conditional evaluation +CREATE OR REPLACE TEMPORARY VIEW sq AS SELECT * FROM VALUES + (1, to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month), + (2, to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month), + (3, to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month), + (4, to_date('2018-01-01'), NULL, interval 1 month), + (5, to_date('2018-01-31'), to_date('2018-05-31'), interval 1 month) AS t(id, a, b, s); +SELECT id, sequence(a, b, s) FROM sq WHERE id IN (1, 4, 5) ORDER BY id; +SELECT id, sequence(a, b, s) FROM sq ORDER BY id; +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) ELSE array() END FROM sq ORDER BY id; +SELECT id, IF(id = 1, sequence(a, b, s), NULL) FROM sq ORDER BY id; +SELECT id, COALESCE(sequence(a, b, s), array(a)) FROM sq WHERE id = 1 OR id = 4 ORDER BY id; +SELECT id, CASE WHEN s > interval 0 month THEN sequence(a, b, s) END FROM sq WHERE id <> 3 ORDER BY id; +SELECT id, CASE WHEN a <= b THEN sequence(a, b, s) END FROM sq WHERE id <> 2 ORDER BY id; +SELECT id FROM sq WHERE id = 1 AND size(sequence(a, b, s)) = 3; +SELECT id FROM sq WHERE id <> 2 AND size(sequence(a, b, s)) = 3 ORDER BY id; +SELECT id, size(sequence(a, b, s)) FROM sq WHERE id IN (1, 5) ORDER BY id; +CREATE OR REPLACE TEMPORARY VIEW sqt AS SELECT * FROM VALUES + (1, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour), + (2, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 0 hour), + (3, timestamp '2018-01-01 03:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) AS t(id, a, b, s); +SELECT id, sequence(a, b, s) FROM sqt WHERE id = 1; +SELECT id, sequence(a, b, s) FROM sqt; +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) END FROM sqt ORDER BY id; +-- ANSI off: same errors +SET spark.sql.ansi.enabled=false; +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month); +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour); +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond); +SELECT sequence(1, 2147483647); +SELECT id, sequence(a, b, s) FROM sq ORDER BY id; +SET spark.sql.ansi.enabled=true; +-- DataFrame-style type errors +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, interval 1 day); +SELECT sequence(true, false); +SELECT sequence(1.5, 3.5); +SELECT sequence('a', 'b', interval 1 day); +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1, 2); +SELECT sequence(); diff --git a/tests/spark-golden/functions/sequence_xml/inputs/sequence_timestamps.sql b/tests/spark-golden/functions/sequence_xml/inputs/sequence_timestamps.sql new file mode 100644 index 000000000..f3819b18f --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/sequence_timestamps.sql @@ -0,0 +1,86 @@ +-- sequence over TIMESTAMP and TIMESTAMP_NTZ +SET spark.sql.session.timeZone=UTC; +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '1' month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0-1' year to month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2020-01-01 00:00:00', interval '1' year); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 01:00:00', interval '0 0:15:0' day to second); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', interval 500 milliseconds); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:01', interval 250000 microseconds); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval '1' day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03'); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1); +SELECT sequence(timestamp '2018-01-01 00:00:03', timestamp '2018-01-01 00:00:00'); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00'); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '-1' month); +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -6 hours); +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval '-6' hour); +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0' month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '0' hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '0' hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0); +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval '1' month); +SELECT sequence(timestamp '2020-02-29 10:00:00', timestamp '2024-03-01 10:00:00', interval '1' year); +SELECT sequence(timestamp '2018-05-31 10:00:00', timestamp '2018-01-01 00:00:00', interval -1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', NULL); +SELECT sequence(NULL, timestamp '2018-01-02 00:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', NULL, interval 1 hour); +SELECT sequence(cast(NULL as timestamp), cast(NULL as timestamp)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', cast(NULL as interval day)); +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 hour)); +SELECT typeof(sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 1 hour)); +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '1' hour)); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00.000003'); +SELECT sequence(timestamp '2018-01-01 00:00:00.5', timestamp '2018-01-01 00:00:03', interval 1 second); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', interval 1 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', date '2018-01-03', interval 1 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp_ntz '2018-01-03 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600L); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1L); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1 hour'); +SELECT sequence(timestamp '2018-01-01 00:00:00', '2018-01-01 00:00:03', interval 1 second); +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '0001-03-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '9999-11-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 month); +-- TIMESTAMP_NTZ +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval '1' month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 6 hours); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '6' hour); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', interval 1 month 2 days); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:03'); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00'); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00', interval -1 second); +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval -1 month); +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval 1 month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 0 month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '0' hour); +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', interval 1 month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', NULL, interval 1 hour); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00'); +-- ANSI off +SET spark.sql.ansi.enabled=false; +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03'); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month); +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1'); +SET spark.sql.ansi.enabled=true; diff --git a/tests/spark-golden/functions/sequence_xml/inputs/sequence_tz.sql b/tests/spark-golden/functions/sequence_xml/inputs/sequence_tz.sql new file mode 100644 index 000000000..c0b119852 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/inputs/sequence_tz.sql @@ -0,0 +1,67 @@ +-- sequence with a DST session time zone (America/Los_Angeles: 2018-03-11 spring forward 02:00->03:00, 2018-11-04 fall back 02:00->01:00) +SET spark.sql.session.timeZone=America/Los_Angeles; +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '24' hour); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1 0:0:0' day to second); +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 1 day); +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 24 hours); +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '1' day); +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '24' hour); +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval '1' hour); +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 1 day); +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval '1' day); +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 24 hours); +SELECT sequence(timestamp '2018-03-11 02:30:00', timestamp '2018-03-12 02:30:00', interval 1 day); +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval 1 month); +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval '1' month); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day 1 hour); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 month 1 day); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00'); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', 86400); +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -1 day); +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval '-1' day); +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -24 hours); +SELECT sequence(timestamp '2018-03-12 02:30:00', timestamp '2018-03-10 02:30:00', interval -1 day); +-- fall back +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '1' day); +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 24 hours); +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '24' hour); +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 1 day); +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 24 hours); +SELECT sequence(timestamp '2018-11-04 00:00:00', timestamp '2018-11-04 04:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', interval 1 day); +SELECT sequence(timestamp '2018-10-04 01:30:00', timestamp '2018-12-04 01:30:00', interval 1 month); +-- default step with a DST zone, timestamps from instants +SELECT sequence(to_timestamp('2018-03-11 09:00:00Z'), to_timestamp('2018-03-11 12:00:00Z'), interval 1 hour); +SELECT sequence(to_timestamp('2018-03-10 08:00:00Z'), to_timestamp('2018-03-12 08:00:00Z'), interval 1 day); +-- DATE steps in DST zone +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 day); +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 24 hours); +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13')); +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 month); +-- TIMESTAMP_NTZ is zone independent +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 1 day); +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 24 hours); +SELECT sequence(timestamp_ntz '2018-03-11 00:00:00', timestamp_ntz '2018-03-11 05:00:00', interval 1 hour); +SELECT sequence(timestamp_ntz '2018-11-04 00:00:00', timestamp_ntz '2018-11-04 04:00:00', interval 1 hour); +SELECT sequence(timestamp_ntz '2018-03-10 02:30:00', timestamp_ntz '2018-03-13 02:30:00', interval 1 day); +-- another zone with a half-hour offset and Southern Hemisphere DST +SET spark.sql.session.timeZone=Australia/Lord_Howe; +SELECT sequence(timestamp '2018-04-01 00:00:00', timestamp '2018-04-02 00:00:00', interval 6 hours); +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 24 hours); +SET spark.sql.session.timeZone=Asia/Kolkata; +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour); +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month); +-- ANSI off in a DST zone +SET spark.sql.session.timeZone=America/Los_Angeles; +SET spark.sql.ansi.enabled=false; +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours); +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day); +SET spark.sql.ansi.enabled=true; +SET spark.sql.session.timeZone=UTC; diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/schema_of_xml.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/schema_of_xml.sql.out new file mode 100644 index 000000000..13af47406 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/schema_of_xml.sql.out @@ -0,0 +1,1738 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

') +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','false')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map()) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','at_')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','v')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','v', 'attributePrefix','@')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','attr')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','', 'valueTag','attr')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: 'valueTag' option should not be empty string. + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','a')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true', 'valueTag','v')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','yes')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: _LEGACY_ERROR_TEMP_2147 +sqlState: None +messageParameters: {'paramName': 'excludeAttribute'} +message: excludeAttribute flag can be true or false. + + +-- !query +SELECT schema_of_xml('

13

', map('excludeattribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('EXCLUDEATTRIBUTE','TRUE')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('unknownOption','x')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', NULL)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml(NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(NULL, map('excludeAttribute','true')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(cast(NULL as string)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(CAST(NULL AS STRING))"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(CAST(NULL AS STRING))" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', true)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', 1)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', named_struct('excludeAttribute','true')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', 'excludeAttribute') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', 'true'), 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '3', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[1, 2]', 'functionName': '`schema_of_xml`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `schema_of_xml` requires [1, 2] parameters but the actual number is 3. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT schema_of_xml() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '0', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[1, 2]', 'functionName': '`schema_of_xml`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `schema_of_xml` requires [1, 2] parameters but the actual number is 0. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT schema_of_xml(1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE +sqlState: 42K09 +messageParameters: {'inputSql': '"1"', 'inputType': '"INT"', 'paramIndex': 'first', 'requiredType': '"STRING"', 'sqlExpr': '"schema_of_xml(1)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "schema_of_xml(1)" due to data type mismatch: The first parameter requires the "STRING" type, however "1" has the type "INT". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(x'3c613e313c2f613e') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE +sqlState: 42K09 +messageParameters: {'inputSql': '"X\'3C613E313C2F613E\'"', 'inputType': '"BINARY"', 'paramIndex': 'first', 'requiredType': '"STRING"', 'sqlExpr': '"schema_of_xml(X\'3C613E313C2F613E\')"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "schema_of_xml(X'3C613E313C2F613E')" due to data type mismatch: The first parameter requires the "STRING" type, however "X'3C613E313C2F613E'" has the type "BINARY". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(concat('

', '1', '

')) +-- !query schema +struct, 1,

)):string> +-- !query output +STRUCT + + +-- !query +SELECT typeof(schema_of_xml('

1

')) +-- !query schema +struct1

)):string> +-- !query output +string + + +-- !query +SELECT schema_of_xml('

1

') AS s +-- !query schema +struct +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') FROM range(3) +-- !query schema +struct1

):string> +-- !query output +STRUCT +STRUCT +STRUCT + + +-- !query +SELECT schema_of_xml(col) FROM VALUES ('

1

') AS t(col) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.NON_FOLDABLE_INPUT +sqlState: 42K09 +messageParameters: {'inputExpr': '"col"', 'inputName': '`xml`', 'inputType': '"STRING"', 'sqlExpr': '"schema_of_xml(col)"'} +message: [DATATYPE_MISMATCH.NON_FOLDABLE_INPUT] Cannot resolve "schema_of_xml(col)" due to data type mismatch: the input `xml` should be a foldable "STRING" expression; however, got "col". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml('

1

', map(k, 'true')) FROM VALUES ('excludeAttribute') AS t(k) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: INTERNAL_ERROR +sqlState: XX000 +messageParameters: {'message': 'Cannot evaluate expression: k#70'} +message: [INTERNAL_ERROR] Cannot evaluate expression: k#70 SQLSTATE: XX000 + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute', v)) FROM VALUES ('true') AS t(v) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: INTERNAL_ERROR +sqlState: XX000 +messageParameters: {'message': 'Cannot evaluate expression: v#71'} +message: [INTERNAL_ERROR] Cannot evaluate expression: v#71 SQLSTATE: XX000 + + +-- !query +SELECT schema_of_xml('

1x

') +-- !query schema +struct1x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

123

') +-- !query schema +struct123

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1x2

') +-- !query schema +struct1x2

):string> +-- !query output +STRUCT, b: STRING> + + +-- !query +SELECT schema_of_xml('

1x

') +-- !query schema +struct1x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

11.5

') +-- !query schema +struct11.5

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1true

') +-- !query schema +struct1true

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

21

') +-- !query schema +struct21

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING> + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING> + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING, c: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING, c: STRUCT<_VALUE: BIGINT, _d: BIGINT>> + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

text

') +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING, _a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text

', map('excludeAttribute','true')) +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING> + + +-- !query +SELECT schema_of_xml('

text

', map('valueTag','val')) +-- !query schema +structtext

):string> +-- !query output +STRUCT<_a: BIGINT, val: STRING> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

text

') +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_VALUE: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1

') +-- !query schema +structtext1

):string> +-- !query output +STRUCT<_VALUE: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1more

') +-- !query schema +structtext1more

):string> +-- !query output +STRUCT<_VALUE: ARRAY, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1more

', map('valueTag','v')) +-- !query schema +structtext1more

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

112

') +-- !query schema +struct112

):string> +-- !query output +STRUCT<_VALUE: ARRAY, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','true')) +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','false')) +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct

1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct

1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

2') +-- !query schema +struct1

2):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

<1>

') +-- !query schema +struct<1>

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

&

') +-- !query schema +struct&

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

A

') +-- !query schema +structA

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

<é>1

') +-- !query schema +struct<é>1

):string> +-- !query output +STRUCT<`é`: BIGINT> + + +-- !query +SELECT schema_of_xml('

123

') +-- !query schema +struct123

):string> +-- !query output +STRUCT<`a-b`: BIGINT, `c.d`: BIGINT, e_f: BIGINT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

xy

') +-- !query schema +structxy

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

xy

', map('excludeAttribute','true')) +-- !query schema +structxy

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

v

', map('attributePrefix','_', 'valueTag','#text')) +-- !query schema +structv

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

') +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','false')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','true')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('prefersDecimal','true')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5true

', map('prefersDecimal','false')) +-- !query schema +struct121474836481.5true

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1.52

', map('prefersDecimal','true')) +-- !query schema +struct1.52

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1.5x

', map('prefersDecimal','true')) +-- !query schema +struct1.5x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1e3

') +-- !query schema +struct1e3

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1e3

', map('prefersDecimal','true')) +-- !query schema +struct1e3

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999

') +-- !query schema +struct99999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999

', map('prefersDecimal','true')) +-- !query schema +struct99999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999999999999999999999999

', map('prefersDecimal','true')) +-- !query schema +struct99999999999999999999999999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

0.1234567890123456789012345678901234567890

', map('prefersDecimal','true')) +-- !query schema +struct0.1234567890123456789012345678901234567890

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

NaNInfinity-Infinity

') +-- !query schema +structNaNInfinity-Infinity

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

-0.0

') +-- !query schema +struct-0.0

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

00123

') +-- !query schema +struct00123

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

+5

') +-- !query schema +struct+5

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

TRUETrue

') +-- !query schema +structTRUETrue

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02 03:04:05

') +-- !query schema +struct2020-01-02 03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:05Z

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05+01:00

') +-- !query schema +struct2020-01-02T03:04:05+01:00

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05.123456

') +-- !query schema +struct2020-01-02T03:04:05.123456

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss', 'timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02

', map('dateFormat','yyyy/MM/dd')) +-- !query schema +struct2020-01-02

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020/01/02

', map('dateFormat','yyyy/MM/dd')) +-- !query schema +struct2020/01/02

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:052020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:052020-01-02T03:04:05Z

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

2020-01-022020-01-02T03:04:05

') +-- !query schema +struct2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12020-01-02

') +-- !query schema +struct12020-01-02

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12147483648

') +-- !query schema +struct12147483648

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

11.5

', map('prefersDecimal','true')) +-- !query schema +struct11.5

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

', map('nullValue','x')) +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

x1

', map('nullValue','x')) +-- !query schema +structx1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

NULL

', map('nullValue','NULL')) +-- !query schema +structNULL

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

NULL1

', map('nullValue','NULL')) +-- !query schema +structNULL1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<`_xmlns:xsi`: STRING, c: STRUCT<`_xsi:nil`: BOOLEAN>> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<`_xmlns:xsi`: STRING, c: ARRAY> + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0.5')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','1.0')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: samplingRatio (0.0) should be greater than 0 + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','-1')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: samplingRatio (-1.0) should be greater than 0 + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','2')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','abc')) +-- !query schema +struct<> +-- !query output +java.lang.NumberFormatException +message: For input string: "abc" + + +-- !query +SELECT schema_of_xml('12') +-- !query schema +struct12):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, b: BIGINT, `ns:a`: BIGINT> + + +-- !query +SELECT schema_of_xml('12', map('ignoreNamespace','true')) +-- !query schema +struct12):string> +-- !query output +STRUCT<_ns: STRING, a: BIGINT, b: BIGINT> + + +-- !query +SELECT schema_of_xml('12', map('ignoreNamespace','false')) +-- !query schema +struct12):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, b: BIGINT, `ns:a`: BIGINT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, a: BIGINT, `ns:a`: STRUCT<_VALUE: BIGINT, `_ns:at`: BIGINT>> + + +-- !query +SELECT schema_of_xml('

12

', map('ignoreNamespace','true')) +-- !query schema +struct12

):string> +-- !query output +STRUCT<_ns: STRING, a: ARRAY>> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_xmlns: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreNamespace','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT<_xmlns: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

123

', map('ignoreNamespace','true')) +-- !query schema +struct123

):string> +-- !query output +STRUCT<_ns: STRING, a: ARRAY> + + +-- !query +SELECT schema_of_xml('

1

', map('rowTag','p')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

12

', map('rowTag','q')) +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

1

', map('rowTag','zzz')) +-- !query schema +struct1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

', map('mode','FAILFAST')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('mode','PERMISSIVE')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('mode','DROPMALFORMED')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: PARSE_MODE_UNSUPPORTED +sqlState: 42601 +messageParameters: {'funcName': '`schema_of_xml`', 'mode': 'DROPMALFORMED'} +message: [PARSE_MODE_UNSUPPORTED] The function `schema_of_xml` doesn't support the DROPMALFORMED mode. Acceptable modes are PERMISSIVE and FAILFAST. SQLSTATE: 42601; + + +-- !query +SELECT schema_of_xml('

1

', map('mode','bogus')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('columnNameOfCorruptRecord','_bad')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('wildcardColName','w')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('charset','UTF-8')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('encoding','UTF-8')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('declaration','x')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('locale','de-DE')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1,5

', map('locale','de-DE', 'prefersDecimal','true')) +-- !query schema +struct1,5

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('multiLine','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('inferSchema','maybe')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: _LEGACY_ERROR_TEMP_2147 +sqlState: None +messageParameters: {'paramName': 'inferSchema'} +message: inferSchema flag can be true or false. + + +-- !query +SELECT schema_of_xml('

1

', map('prefersDecimal','maybe')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: For input string: "maybe" + + +-- !query +SELECT schema_of_xml('

1

', map('timeZone','America/Los_Angeles')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('timeZone','Not/AZone')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkDateTimeException +errorClass: INVALID_TIMEZONE +sqlState: 22009 +messageParameters: {'timeZone': 'Not/AZone'} +message: [INVALID_TIMEZONE] The timezone: Not/AZone is invalid. The timezone must be either a region-based zone ID or a zone offset. Region IDs must have the form 'area/city', such as 'America/Los_Angeles'. Zone offsets must be in the format '(+|-)HH', '(+|-)HH:mm’ or '(+|-)HH:mm:ss', e.g '-08' , '+01:00' or '-13:33:33', and must be in the range from -18:00 to +18:00. 'Z' and 'UTC' are accepted as synonyms for '+00:00'. SQLSTATE: 22009 +cause: java.time.zone.ZoneRulesException: Unknown time-zone ID: Not/AZone + + +-- !query +SELECT schema_of_xml('

1

', map('validateName','false')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0.5', 'attributePrefix','_', 'valueTag','_v', 'excludeAttribute','true', 'ignoreNamespace','true', 'prefersDecimal','true', 'inferSchema','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml(' ') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('not xml') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1') +-- !query schema +struct1):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

&unknown;

') +-- !query schema +struct&unknown;

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('<') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

garbage') +-- !query schema +struct1

garbage):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

', map('mode','FAILFAST')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: MALFORMED_RECORD_IN_PARSING.WITHOUT_SUGGESTION +sqlState: 22023 +messageParameters: {'badRecord': '_corrupt_record', 'failFastMode': 'FAILFAST'} +message: [MALFORMED_RECORD_IN_PARSING.WITHOUT_SUGGESTION] Malformed records are detected in record parsing: _corrupt_record. +cause: java.lang.RuntimeException: org.apache.hadoop.shaded.com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element

+cause: org.apache.hadoop.shaded.com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element

+ + +-- !query +SELECT schema_of_xml('

', map('mode','PERMISSIVE')) +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

', map('mode','DROPMALFORMED')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: PARSE_MODE_UNSUPPORTED +sqlState: 42601 +messageParameters: {'funcName': '`schema_of_xml`', 'mode': 'DROPMALFORMED'} +message: [PARSE_MODE_UNSUPPORTED] The function `schema_of_xml` doesn't support the DROPMALFORMED mode. Acceptable modes are PERMISSIVE and FAILFAST. SQLSTATE: 42601; + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

') +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml(NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

') +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:05Z

):string> +-- !query output +STRUCT + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT from_xml('

13

', schema_of_xml('

13

')) +-- !query schema +struct13

):struct>>> +-- !query output +{[{1, 2}, {3, null}]} + + +-- !query +SELECT from_xml('

13

', schema_of_xml('

13

', map('excludeAttribute','true')), map('excludeAttribute','true')) +-- !query schema +struct13

):struct>> +-- !query output +{[1, 3]} + + +-- !query +SELECT CASE WHEN 1 = 2 THEN schema_of_xml('

') ELSE 'ok' END +-- !query schema +struct) ELSE ok END:string> +-- !query output +ok + + +-- !query +SELECT IF(false, schema_of_xml('

'), 'ok') +-- !query schema +struct<(IF(false, schema_of_xml(

), ok)):string> +-- !query output +ok + + +-- !query +SELECT COALESCE('ok', schema_of_xml('

')) +-- !query schema +struct)):string> +-- !query output +ok + + +-- !query +SELECT * FROM range(2) WHERE id = 5 AND schema_of_xml('

') = 'x' +-- !query schema +struct +-- !query output + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_calendar.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_calendar.sql.out new file mode 100644 index 000000000..2c7350421 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_calendar.sql.out @@ -0,0 +1,686 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 12)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1, 12)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 0, 0, 1)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), make_interval(0, -1)) +-- !query schema +struct> +-- !query output +[2018-05-31, 2018-04-30, 2018-03-31, 2018-02-28, 2018-01-31] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, -1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 months + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 0)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval()) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1, 0, -2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-30, 2018-02-25] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), cast('1 month' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), cast('1 month 2 days' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast('1 day' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1))) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 00:00:00, 2018-03-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 03:00:00, 2018-03-05 06:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', make_interval(0, 0, 0, 0, 6)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', make_interval(0, 0, 0, 0, 0, 0, 0.5)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.5, 2018-01-01 00:00:01, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1)) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, -1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 months + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval()) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', make_interval(0, 1, 0, -2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-30 00:00:00, 2018-02-25 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-03-02 00:00:00, 2018-02-04 00:00:00, 2018-01-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 03:00:00, 2018-03-05 06:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval()) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 01:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 01:00:00, 2018-03-12 02:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-04 23:00:00, 2018-11-05 23:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-11-04 01:30:00, 2018-11-05 01:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 12)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 13:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', make_interval(0, 0, 0, -1)) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days 3 hours'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT typeof(interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.legacy.interval.enabled=true +-- !query schema +struct +-- !query output +spark.sql.legacy.interval.enabled true + + +-- !query +SELECT typeof(interval 1 month 2 days) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT typeof(interval 1 month) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT typeof(interval 1 day) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 00:00:00, 2018-03-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SET spark.sql.legacy.interval.enabled=false +-- !query schema +struct +-- !query output +spark.sql.legacy.interval.enabled false + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_dates.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_dates.sql.out new file mode 100644 index 000000000..bf26b1d62 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_dates.sql.out @@ -0,0 +1,781 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2020-01-01'), interval '1' year) +-- !query schema +struct> +-- !query output +[2018-01-01, 2019-01-01, 2020-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1 0' day to hour) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '2 0:0:0' day to second) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-03, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 1 hour) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-05'), to_date('2018-01-01')) +-- !query schema +struct> +-- !query output +[2018-01-05, 2018-01-04, 2018-01-03, 2018-01-02, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01')) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-01, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' month) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-01, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' day) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-28, 2018-02-27, 2018-02-26, 2018-02-25, 2018-02-24, 2018-02-23, 2018-02-22, 2018-02-21, 2018-02-20, 2018-02-19, 2018-02-18, 2018-02-17, 2018-02-16, 2018-02-15, 2018-02-14, 2018-02-13, 2018-02-12, 2018-02-11, 2018-02-10, 2018-02-09, 2018-02-08, 2018-02-07, 2018-02-06, 2018-02-05, 2018-02-04, 2018-02-03, 2018-02-02, 2018-02-01, 2018-01-31, 2018-01-30, 2018-01-29, 2018-01-28, 2018-01-27, 2018-01-26, 2018-01-25, 2018-01-24, 2018-01-23, 2018-01-22, 2018-01-21, 2018-01-20, 2018-01-19, 2018-01-18, 2018-01-17, 2018-01-16, 2018-01-15, 2018-01-14, 2018-01-13, 2018-01-12, 2018-01-11, 2018-01-10, 2018-01-09, 2018-01-08, 2018-01-07, 2018-01-06, 2018-01-05, 2018-01-04, 2018-01-03, 2018-01-02, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 17532 to 17536 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2020-01-31'), to_date('2020-05-31'), interval 1 month) +-- !query schema +struct> +-- !query output +[2020-01-31, 2020-02-29, 2020-03-31, 2020-04-30, 2020-05-31] + + +-- !query +SELECT sequence(to_date('2020-02-29'), to_date('2024-03-01'), interval '1' year) +-- !query schema +struct> +-- !query output +[2020-02-29, 2021-02-28, 2022-02-28, 2023-02-28, 2024-02-29] + + +-- !query +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), interval -1 month) +-- !query schema +struct> +-- !query output +[2018-05-31, 2018-04-30, 2018-03-31, 2018-02-28, 2018-01-31] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), NULL)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), NULL)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(NULL, to_date('2018-01-05'), interval 1 day) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), NULL, interval 1 day) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(cast(NULL as date), cast(NULL as date)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval day)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval month)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'))) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(to_date('0001-01-01'), to_date('0001-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[0001-01-01, 0001-02-01, 0001-03-01] + + +-- !query +SELECT sequence(to_date('9999-11-01'), to_date('9999-12-31'), interval 1 month) +-- !query schema +struct> +-- !query output +[9999-11-01, 9999-12-01] + + +-- !query +SELECT sequence(to_date('1582-10-01'), to_date('1582-10-20'), interval 5 days) +-- !query schema +struct> +-- !query output +[1582-10-01, 1582-10-06, 1582-10-11, 1582-10-16] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 12 hours) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 1 microsecond) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 86400000000 microseconds) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT size(sequence(to_date('2000-01-01'), to_date('2000-12-31'))) +-- !query schema +struct +-- !query output +366 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1 day') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1 day)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1 day)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), 5, interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), 5, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), 5, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(to_date('2018-01-01')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '1', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 1. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(date '2018-01-01', timestamp '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(date '2018-01-01', timestamp_ntz '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' year to month) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: INVALID_INTERVAL_FORMAT.UNMATCHED_FORMAT_STRING +sqlState: 22006 +messageParameters: {'input': '1', 'intervalStr': 'year-month', 'supportedFormat': "`[+|-]y-m`, `INTERVAL [+|-]'[+|-]y-m' YEAR TO MONTH`", 'typeName': 'interval year to month'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '10' day) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 week) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-08, 2018-01-15, 2018-01-22, 2018-01-29, 2018-02-05, 2018-02-12, 2018-02-19, 2018-02-26] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-02-01'), interval 1 week) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-08, 2018-01-15, 2018-01-22, 2018-01-29] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month, 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 quarter) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: PARSE_SYNTAX_ERROR +sqlState: 42601 +messageParameters: {'error': "'quarter'", 'hint': ''} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 3 months) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-04-01, 2018-07-01, 2018-10-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 1 year 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2020-12-01'), interval 1 year 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2019-02-01, 2020-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1 1' year to month) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: INVALID_INTERVAL_FORMAT.UNMATCHED_FORMAT_STRING +sqlState: 22006 +messageParameters: {'input': '1 1', 'intervalStr': 'year-month', 'supportedFormat': "`[+|-]y-m`, `INTERVAL [+|-]'[+|-]y-m' YEAR TO MONTH`", 'typeName': 'interval year to month'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 0 months 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 0 months 1 day'} +message: + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), 2018-01-05, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), 2018-01-05, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_errors.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_errors.sql.out new file mode 100644 index 000000000..a95cc2c91 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_errors.sql.out @@ -0,0 +1,661 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '0' day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 17532 to 17536 by -1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by -3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514851200000000 to 1514764800000000 by 3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 month 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 0 month 0 day'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval -1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month 0 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 0 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-03-02'), to_date('2018-01-01'), interval -1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval -1 month -2 days'} +message: + + +-- !query +SELECT size(sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day)) +-- !query schema +struct +-- !query output +5 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT size(sequence(to_date('0001-01-01'), to_date('9999-12-31'), interval 1 day)) +-- !query schema +struct +-- !query output +3652059 + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '315537811200000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 315537811200000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 millisecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '315537811200001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 315537811200001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT size(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:05', interval 1 microsecond)) +-- !query schema +struct +-- !query output +5000001 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-02-01 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2678400000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2678400000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483647', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483647 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1L, 2147483648L) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483648', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483648 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483633) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483633', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483633 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(-2147483648, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '4294967296', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 4294967296 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(-2147483648, 2147483647, 2147483647) +-- !query schema +struct> +-- !query output +[-2147483648, -1, 2147483646] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 106751991 days) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 9999999999 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION +sqlState: 22006 +messageParameters: {'input': ' 9999999999 days'} +message: [INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION] Error parsing ' 9999999999 days' to interval. Please ensure that the value provided is in a valid format for defining an interval. You can reference the documentation for the correct format. Uncaught arithmetic exception while parsing ' 9999999999 days'. SQLSTATE: 22006 + + +-- !query +CREATE OR REPLACE TEMPORARY VIEW sq AS SELECT * FROM VALUES + (1, to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month), + (2, to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month), + (3, to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month), + (4, to_date('2018-01-01'), NULL, interval 1 month), + (5, to_date('2018-01-31'), to_date('2018-05-31'), interval 1 month) AS t(id, a, b, s) +-- !query schema +struct<> +-- !query output + + +-- !query +SELECT id, sequence(a, b, s) FROM sq WHERE id IN (1, 4, 5) ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id, sequence(a, b, s) FROM sq ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) ELSE array() END FROM sq ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 [] +3 [] +4 [] +5 [] + + +-- !query +SELECT id, IF(id = 1, sequence(a, b, s), NULL) FROM sq ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 NULL +3 NULL +4 NULL +5 NULL + + +-- !query +SELECT id, COALESCE(sequence(a, b, s), array(a)) FROM sq WHERE id = 1 OR id = 4 ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +4 [2018-01-01] + + +-- !query +SELECT id, CASE WHEN s > interval 0 month THEN sequence(a, b, s) END FROM sq WHERE id <> 3 ORDER BY id +-- !query schema +struct INTERVAL '0' MONTH) THEN sequence(a, b, s) END:array> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 NULL +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id, CASE WHEN a <= b THEN sequence(a, b, s) END FROM sq WHERE id <> 2 ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +3 NULL +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id FROM sq WHERE id = 1 AND size(sequence(a, b, s)) = 3 +-- !query schema +struct +-- !query output +1 + + +-- !query +SELECT id FROM sq WHERE id <> 2 AND size(sequence(a, b, s)) = 3 ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3243 +sqlState: None +messageParameters: {'start': '1519862400000000', 'step': '1', 'stop': '1514764800000000'} +message: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT id, size(sequence(a, b, s)) FROM sq WHERE id IN (1, 5) ORDER BY id +-- !query schema +struct +-- !query output +1 3 +5 5 + + +-- !query +CREATE OR REPLACE TEMPORARY VIEW sqt AS SELECT * FROM VALUES + (1, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour), + (2, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 0 hour), + (3, timestamp '2018-01-01 03:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) AS t(id, a, b, s) +-- !query schema +struct<> +-- !query output + + +-- !query +SELECT id, sequence(a, b, s) FROM sqt WHERE id = 1 +-- !query schema +struct> +-- !query output +1 [2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] + + +-- !query +SELECT id, sequence(a, b, s) FROM sqt +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514775600000000 by 0 + + +-- !query +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) END FROM sqt ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] +2 NULL +3 NULL + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514851200000000 to 1514764800000000 by 3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483647', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483647 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT id, sequence(a, b, s) FROM sq ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(true, false) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(true, false)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(true, false)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(1.5, 3.5) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(1.5, 3.5)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(1.5, 3.5)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence('a', 'b', interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(a, b, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(a, b, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1, 2) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '5', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 5. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '0', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 0. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_timestamps.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_timestamps.sql.out new file mode 100644 index 000000000..583711e40 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_timestamps.sql.out @@ -0,0 +1,732 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2020-01-01 00:00:00', interval '1' year) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2019-01-01 00:00:00, 2020-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 01:00:00', interval '0 0:15:0' day to second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:15:00, 2018-01-01 00:30:00, 2018-01-01 00:45:00, 2018-01-01 01:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', interval 500 milliseconds) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.5, 2018-01-01 00:00:01, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:01', interval 250000 microseconds) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.25, 2018-01-01 00:00:00.5, 2018-01-01 00:00:00.75, 2018-01-01 00:00:01] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days 3 hours'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-01 00:00:03\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-01 00:00:03', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:03', timestamp '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '-1' month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -6 hours) +-- !query schema +struct> +-- !query output +[2018-01-02 00:00:00, 2018-01-01 18:00:00, 2018-01-01 12:00:00, 2018-01-01 06:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval '-6' hour) +-- !query schema +struct> +-- !query output +[2018-01-02 00:00:00, 2018-01-01 18:00:00, 2018-01-01 12:00:00, 2018-01-01 06:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by -3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0' month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '0' hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '0' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2020-02-29 10:00:00', timestamp '2024-03-01 10:00:00', interval '1' year) +-- !query schema +struct> +-- !query output +[2020-02-29 10:00:00, 2021-02-28 10:00:00, 2022-02-28 10:00:00, 2023-02-28 10:00:00, 2024-02-29 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-05-31 10:00:00', timestamp '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-05-31 10:00:00, 2018-04-30 10:00:00, 2018-03-31 10:00:00, 2018-02-28 10:00:00, 2018-01-31 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', NULL)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', NULL)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(NULL, timestamp '2018-01-02 00:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', NULL, interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(cast(NULL as timestamp), cast(NULL as timestamp)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', cast(NULL as interval day)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 1 hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '1' hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00.000003') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00.5', timestamp '2018-01-01 00:00:03', interval 1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00.5, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02.5] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', date '2018-01-03', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp_ntz '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 3600)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 3600)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600L) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 3600)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 3600)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1L) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-01 00:00:03\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-01 00:00:03', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1 hour') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 1 hour)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 1 hour)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', '2018-01-01 00:00:03', interval 1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:01, 2018-01-01 00:00:02, 2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '0001-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[0001-01-01 00:00:00, 0001-02-01 00:00:00, 0001-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '9999-11-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[9999-11-01 00:00:00, 9999-12-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00', interval -1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03, 2018-01-01 00:00:02, 2018-01-01 00:00:01, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '0' hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', NULL, interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_tz.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_tz.sql.out new file mode 100644 index 000000000..c6c5d2c3d --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.2.0/sequence_tz.sql.out @@ -0,0 +1,489 @@ +-- Generated by run_oracle.py against Spark 4.2.0 + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1 0:0:0' day to second) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval '1' hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 02:30:00', timestamp '2018-03-12 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-11 03:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 01:00:00, 2018-03-12 02:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 month 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 1 day'} +message: + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00') +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', 86400) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-03-10 00:00:00\', TIMESTAMP \'2018-03-13 00:00:00\', 86400)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-03-10 00:00:00', TIMESTAMP '2018-03-13 00:00:00', 86400)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -1 day) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval '-1' day) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -24 hours) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-12 02:30:00', timestamp '2018-03-10 02:30:00', interval -1 day) +-- !query schema +struct> +-- !query output +[2018-03-12 02:30:00, 2018-03-11 03:30:00, 2018-03-10 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-03 12:00:00, 2018-11-04 12:00:00, 2018-11-05 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-11-03 12:00:00, 2018-11-04 12:00:00, 2018-11-05 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 00:00:00', timestamp '2018-11-04 04:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-11-04 00:00:00, 2018-11-04 01:00:00, 2018-11-04 01:00:00, 2018-11-04 02:00:00, 2018-11-04 03:00:00, 2018-11-04 04:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-04 01:30:00, 2018-11-05 01:30:00] + + +-- !query +SELECT sequence(timestamp '2018-10-04 01:30:00', timestamp '2018-12-04 01:30:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-10-04 01:30:00, 2018-11-04 01:30:00, 2018-12-04 01:30:00] + + +-- !query +SELECT sequence(to_timestamp('2018-03-11 09:00:00Z'), to_timestamp('2018-03-11 12:00:00Z'), interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(to_timestamp('2018-03-10 08:00:00Z'), to_timestamp('2018-03-12 08:00:00Z'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13')) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-03-10] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-11 00:00:00', timestamp_ntz '2018-03-11 05:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 02:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-11-04 00:00:00', timestamp_ntz '2018-11-04 04:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-11-04 00:00:00, 2018-11-04 01:00:00, 2018-11-04 02:00:00, 2018-11-04 03:00:00, 2018-11-04 04:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 02:30:00', timestamp_ntz '2018-03-13 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 02:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SET spark.sql.session.timeZone=Australia/Lord_Howe +-- !query schema +struct +-- !query output +spark.sql.session.timeZone Australia/Lord_Howe + + +-- !query +SELECT sequence(timestamp '2018-04-01 00:00:00', timestamp '2018-04-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-04-01 00:00:00, 2018-04-01 05:30:00, 2018-04-01 11:30:00, 2018-04-01 17:30:00, 2018-04-01 23:30:00] + + +-- !query +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-10-06 00:00:00, 2018-10-07 00:00:00, 2018-10-08 00:00:00, 2018-10-09 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-10-06 00:00:00, 2018-10-07 00:00:00, 2018-10-08 00:00:00, 2018-10-09 00:00:00] + + +-- !query +SET spark.sql.session.timeZone=Asia/Kolkata +-- !query schema +struct +-- !query output +spark.sql.session.timeZone Asia/Kolkata + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/schema_of_xml.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/schema_of_xml.sql.out new file mode 100644 index 000000000..f41c0f959 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/schema_of_xml.sql.out @@ -0,0 +1,1738 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

') +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','false')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map()) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','at_')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','v')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','v', 'attributePrefix','@')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','attr')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','', 'valueTag','attr')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('valueTag','')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: 'valueTag' option should not be empty string. + + +-- !query +SELECT schema_of_xml('

13

', map('attributePrefix','a')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true', 'valueTag','v')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','yes')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: _LEGACY_ERROR_TEMP_2147 +sqlState: None +messageParameters: {'paramName': 'excludeAttribute'} +message: excludeAttribute flag can be true or false. + + +-- !query +SELECT schema_of_xml('

13

', map('excludeattribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('EXCLUDEATTRIBUTE','TRUE')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

', map('unknownOption','x')) +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', NULL)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml(NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(NULL, map('excludeAttribute','true')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(cast(NULL as string)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(CAST(NULL AS STRING))"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(CAST(NULL AS STRING))" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', true)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', 1)) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_STRING_TYPE +sqlState: 42K06 +messageParameters: {'mapType': '"MAP"'} +message: [INVALID_OPTIONS.NON_STRING_TYPE] Invalid options: A type of keys and values in `map()` must be string, but got "MAP". SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', named_struct('excludeAttribute','true')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', 'excludeAttribute') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: INVALID_OPTIONS.NON_MAP_FUNCTION +sqlState: 42K06 +messageParameters: {} +message: [INVALID_OPTIONS.NON_MAP_FUNCTION] Invalid options: Must use the `map()` function for options. SQLSTATE: 42K06; line 1 pos 7 + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute', 'true'), 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '3', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[1, 2]', 'functionName': '`schema_of_xml`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `schema_of_xml` requires [1, 2] parameters but the actual number is 3. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT schema_of_xml() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '0', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[1, 2]', 'functionName': '`schema_of_xml`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `schema_of_xml` requires [1, 2] parameters but the actual number is 0. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT schema_of_xml(1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE +sqlState: 42K09 +messageParameters: {'inputSql': '"1"', 'inputType': '"INT"', 'paramIndex': 'first', 'requiredType': '"STRING"', 'sqlExpr': '"schema_of_xml(1)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "schema_of_xml(1)" due to data type mismatch: The first parameter requires the "STRING" type, however "1" has the type "INT". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(x'3c613e313c2f613e') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE +sqlState: 42K09 +messageParameters: {'inputSql': '"X\'3C613E313C2F613E\'"', 'inputType': '"BINARY"', 'paramIndex': 'first', 'requiredType': '"STRING"', 'sqlExpr': '"schema_of_xml(X\'3C613E313C2F613E\')"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_INPUT_TYPE] Cannot resolve "schema_of_xml(X'3C613E313C2F613E')" due to data type mismatch: The first parameter requires the "STRING" type, however "X'3C613E313C2F613E'" has the type "BINARY". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml(concat('

', '1', '

')) +-- !query schema +struct, 1,

)):string> +-- !query output +STRUCT + + +-- !query +SELECT typeof(schema_of_xml('

1

')) +-- !query schema +struct1

)):string> +-- !query output +string + + +-- !query +SELECT schema_of_xml('

1

') AS s +-- !query schema +struct +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') FROM range(3) +-- !query schema +struct1

):string> +-- !query output +STRUCT +STRUCT +STRUCT + + +-- !query +SELECT schema_of_xml(col) FROM VALUES ('

1

') AS t(col) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.NON_FOLDABLE_INPUT +sqlState: 42K09 +messageParameters: {'inputExpr': '"col"', 'inputName': '`xml`', 'inputType': '"STRING"', 'sqlExpr': '"schema_of_xml(col)"'} +message: [DATATYPE_MISMATCH.NON_FOLDABLE_INPUT] Cannot resolve "schema_of_xml(col)" due to data type mismatch: the input `xml` should be a foldable "STRING" expression; however, got "col". SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SELECT schema_of_xml('

1

', map(k, 'true')) FROM VALUES ('excludeAttribute') AS t(k) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: INTERNAL_ERROR +sqlState: XX000 +messageParameters: {'message': 'Cannot evaluate expression: k#70'} +message: [INTERNAL_ERROR] Cannot evaluate expression: k#70 SQLSTATE: XX000 + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute', v)) FROM VALUES ('true') AS t(v) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: INTERNAL_ERROR +sqlState: XX000 +messageParameters: {'message': 'Cannot evaluate expression: v#71'} +message: [INTERNAL_ERROR] Cannot evaluate expression: v#71 SQLSTATE: XX000 + + +-- !query +SELECT schema_of_xml('

1x

') +-- !query schema +struct1x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

123

') +-- !query schema +struct123

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1x2

') +-- !query schema +struct1x2

):string> +-- !query output +STRUCT, b: STRING> + + +-- !query +SELECT schema_of_xml('

1x

') +-- !query schema +struct1x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

11.5

') +-- !query schema +struct11.5

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1true

') +-- !query schema +struct1true

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

21

') +-- !query schema +struct21

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING> + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING> + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING, c: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_a: BIGINT, _b: STRING, c: STRUCT<_VALUE: BIGINT, _d: BIGINT>> + + +-- !query +SELECT schema_of_xml('

1

', map('excludeAttribute','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

text

') +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING, _a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text

', map('excludeAttribute','true')) +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING> + + +-- !query +SELECT schema_of_xml('

text

', map('valueTag','val')) +-- !query schema +structtext

):string> +-- !query output +STRUCT<_a: BIGINT, val: STRING> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

text

') +-- !query schema +structtext

):string> +-- !query output +STRUCT<_VALUE: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_VALUE: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1

') +-- !query schema +structtext1

):string> +-- !query output +STRUCT<_VALUE: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1more

') +-- !query schema +structtext1more

):string> +-- !query output +STRUCT<_VALUE: ARRAY, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

text1more

', map('valueTag','v')) +-- !query schema +structtext1more

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

112

') +-- !query schema +struct112

):string> +-- !query output +STRUCT<_VALUE: ARRAY, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','true')) +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreSurroundingSpaces','false')) +-- !query schema +struct 1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct

1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct

1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

2') +-- !query schema +struct1

2):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

<1>

') +-- !query schema +struct<1>

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

&

') +-- !query schema +struct&

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

A

') +-- !query schema +structA

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

<é>1

') +-- !query schema +struct<é>1

):string> +-- !query output +STRUCT<`é`: BIGINT> + + +-- !query +SELECT schema_of_xml('

123

') +-- !query schema +struct123

):string> +-- !query output +STRUCT<`a-b`: BIGINT, `c.d`: BIGINT, e_f: BIGINT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

xy

') +-- !query schema +structxy

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

xy

', map('excludeAttribute','true')) +-- !query schema +structxy

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

v

', map('attributePrefix','_', 'valueTag','#text')) +-- !query schema +structv

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

') +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','false')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('inferSchema','true')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5truex2020-01-022020-01-02T03:04:05

', map('prefersDecimal','true')) +-- !query schema +struct121474836481.5truex2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

121474836481.5true

', map('prefersDecimal','false')) +-- !query schema +struct121474836481.5true

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1.52

', map('prefersDecimal','true')) +-- !query schema +struct1.52

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1.5x

', map('prefersDecimal','true')) +-- !query schema +struct1.5x

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1e3

') +-- !query schema +struct1e3

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1e3

', map('prefersDecimal','true')) +-- !query schema +struct1e3

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999

') +-- !query schema +struct99999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999

', map('prefersDecimal','true')) +-- !query schema +struct99999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

99999999999999999999999999999999999999999

', map('prefersDecimal','true')) +-- !query schema +struct99999999999999999999999999999999999999999

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

0.1234567890123456789012345678901234567890

', map('prefersDecimal','true')) +-- !query schema +struct0.1234567890123456789012345678901234567890

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

NaNInfinity-Infinity

') +-- !query schema +structNaNInfinity-Infinity

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

-0.0

') +-- !query schema +struct-0.0

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

00123

') +-- !query schema +struct00123

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

+5

') +-- !query schema +struct+5

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

TRUETrue

') +-- !query schema +structTRUETrue

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02 03:04:05

') +-- !query schema +struct2020-01-02 03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:05Z

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05+01:00

') +-- !query schema +struct2020-01-02T03:04:05+01:00

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05.123456

') +-- !query schema +struct2020-01-02T03:04:05.123456

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

', map('timestampFormat','yyyy-MM-dd''T''HH:mm:ss', 'timestampNTZFormat','yyyy-MM-dd''T''HH:mm:ss')) +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02

', map('dateFormat','yyyy/MM/dd')) +-- !query schema +struct2020-01-02

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020/01/02

', map('dateFormat','yyyy/MM/dd')) +-- !query schema +struct2020/01/02

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:052020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:052020-01-02T03:04:05Z

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

2020-01-022020-01-02T03:04:05

') +-- !query schema +struct2020-01-022020-01-02T03:04:05

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12020-01-02

') +-- !query schema +struct12020-01-02

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

12147483648

') +-- !query schema +struct12147483648

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

11.5

', map('prefersDecimal','true')) +-- !query schema +struct11.5

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

', map('nullValue','x')) +-- !query schema +struct

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

x1

', map('nullValue','x')) +-- !query schema +structx1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

NULL

', map('nullValue','NULL')) +-- !query schema +structNULL

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

NULL1

', map('nullValue','NULL')) +-- !query schema +structNULL1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct

):string> +-- !query output +STRUCT<`_xmlns:xsi`: STRING, c: STRUCT<`_xsi:nil`: BOOLEAN>> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<`_xmlns:xsi`: STRING, c: ARRAY> + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0.5')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','1.0')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: samplingRatio (0.0) should be greater than 0 + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','-1')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: samplingRatio (-1.0) should be greater than 0 + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','2')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','abc')) +-- !query schema +struct<> +-- !query output +java.lang.NumberFormatException +message: For input string: "abc" + + +-- !query +SELECT schema_of_xml('12') +-- !query schema +struct12):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, b: BIGINT, `ns:a`: BIGINT> + + +-- !query +SELECT schema_of_xml('12', map('ignoreNamespace','true')) +-- !query schema +struct12):string> +-- !query output +STRUCT<_ns: STRING, a: BIGINT, b: BIGINT> + + +-- !query +SELECT schema_of_xml('12', map('ignoreNamespace','false')) +-- !query schema +struct12):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, b: BIGINT, `ns:a`: BIGINT> + + +-- !query +SELECT schema_of_xml('

12

') +-- !query schema +struct12

):string> +-- !query output +STRUCT<`_xmlns:ns`: STRING, a: BIGINT, `ns:a`: STRUCT<_VALUE: BIGINT, `_ns:at`: BIGINT>> + + +-- !query +SELECT schema_of_xml('

12

', map('ignoreNamespace','true')) +-- !query schema +struct12

):string> +-- !query output +STRUCT<_ns: STRING, a: ARRAY>> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_xmlns: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

1

', map('ignoreNamespace','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT<_xmlns: STRING, a: BIGINT> + + +-- !query +SELECT schema_of_xml('

123

', map('ignoreNamespace','true')) +-- !query schema +struct123

):string> +-- !query output +STRUCT<_ns: STRING, a: ARRAY> + + +-- !query +SELECT schema_of_xml('

1

', map('rowTag','p')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

12

', map('rowTag','q')) +-- !query schema +struct12

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

1

', map('rowTag','zzz')) +-- !query schema +struct1

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

1

', map('mode','FAILFAST')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('mode','PERMISSIVE')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('mode','DROPMALFORMED')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: PARSE_MODE_UNSUPPORTED +sqlState: 42601 +messageParameters: {'funcName': '`schema_of_xml`', 'mode': 'DROPMALFORMED'} +message: [PARSE_MODE_UNSUPPORTED] The function `schema_of_xml` doesn't support the DROPMALFORMED mode. Acceptable modes are PERMISSIVE and FAILFAST. SQLSTATE: 42601; + + +-- !query +SELECT schema_of_xml('

1

', map('mode','bogus')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('columnNameOfCorruptRecord','_bad')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('wildcardColName','w')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('charset','UTF-8')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('encoding','UTF-8')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('declaration','x')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('locale','de-DE')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1,5

', map('locale','de-DE', 'prefersDecimal','true')) +-- !query schema +struct1,5

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('multiLine','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('inferSchema','maybe')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: _LEGACY_ERROR_TEMP_2147 +sqlState: None +messageParameters: {'paramName': 'inferSchema'} +message: inferSchema flag can be true or false. + + +-- !query +SELECT schema_of_xml('

1

', map('prefersDecimal','maybe')) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: For input string: "maybe" + + +-- !query +SELECT schema_of_xml('

1

', map('timeZone','America/Los_Angeles')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('timeZone','Not/AZone')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkDateTimeException +errorClass: INVALID_TIMEZONE +sqlState: 22009 +messageParameters: {'timeZone': 'Not/AZone'} +message: [INVALID_TIMEZONE] The timezone: Not/AZone is invalid. The timezone must be either a region-based zone ID or a zone offset. Region IDs must have the form 'area/city', such as 'America/Los_Angeles'. Zone offsets must be in the format '(+|-)HH', '(+|-)HH:mm’ or '(+|-)HH:mm:ss', e.g '-08' , '+01:00' or '-13:33:33', and must be in the range from -18:00 to +18:00. 'Z' and 'UTC' are accepted as synonyms for '+00:00'. SQLSTATE: 22009 +cause: java.time.zone.ZoneRulesException: Unknown time-zone ID: Not/AZone + + +-- !query +SELECT schema_of_xml('

1

', map('validateName','false')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

', map('samplingRatio','0.5', 'attributePrefix','_', 'valueTag','_v', 'excludeAttribute','true', 'ignoreNamespace','true', 'prefersDecimal','true', 'inferSchema','true')) +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml(' ') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('not xml') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1') +-- !query schema +struct1):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

&unknown;

') +-- !query schema +struct&unknown;

):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('<') +-- !query schema +struct +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

garbage') +-- !query schema +struct1

garbage):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

', map('mode','FAILFAST')) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkException +errorClass: MALFORMED_RECORD_IN_PARSING.WITHOUT_SUGGESTION +sqlState: 22023 +messageParameters: {'badRecord': '_corrupt_record', 'failFastMode': 'FAILFAST'} +message: [MALFORMED_RECORD_IN_PARSING.WITHOUT_SUGGESTION] Malformed records are detected in record parsing: _corrupt_record. +cause: java.lang.RuntimeException: org.apache.hadoop.shaded.com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element

+cause: org.apache.hadoop.shaded.com.ctc.wstx.exc.WstxEOFException: Unexpected EOF; was expecting a close tag for element

+ + +-- !query +SELECT schema_of_xml('

', map('mode','PERMISSIVE')) +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

', map('mode','DROPMALFORMED')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: PARSE_MODE_UNSUPPORTED +sqlState: 42601 +messageParameters: {'funcName': '`schema_of_xml`', 'mode': 'DROPMALFORMED'} +message: [PARSE_MODE_UNSUPPORTED] The function `schema_of_xml` doesn't support the DROPMALFORMED mode. Acceptable modes are PERMISSIVE and FAILFAST. SQLSTATE: 42601; + + +-- !query +SELECT schema_of_xml('

', map('excludeAttribute','true')) +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

1

') +-- !query schema +struct1

):string> +-- !query output +STRUCT + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT schema_of_xml('

13

', map('excludeAttribute','true')) +-- !query schema +struct13

):string> +-- !query output +STRUCT> + + +-- !query +SELECT schema_of_xml('

13

') +-- !query schema +struct13

):string> +-- !query output +STRUCT>> + + +-- !query +SELECT schema_of_xml('

') +-- !query schema +struct):string> +-- !query output +STRUCT<_corrupt_record: STRING> + + +-- !query +SELECT schema_of_xml(NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.UNEXPECTED_NULL +sqlState: 42K09 +messageParameters: {'exprName': 'xml', 'sqlExpr': '"schema_of_xml(NULL)"'} +message: [DATATYPE_MISMATCH.UNEXPECTED_NULL] Cannot resolve "schema_of_xml(NULL)" due to data type mismatch: The xml must not be null. SQLSTATE: 42K09; line 1 pos 7; + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05

') +-- !query schema +struct2020-01-02T03:04:05

):string> +-- !query output +STRUCT + + +-- !query +SELECT schema_of_xml('

2020-01-02T03:04:05Z

') +-- !query schema +struct2020-01-02T03:04:05Z

):string> +-- !query output +STRUCT + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT from_xml('

13

', schema_of_xml('

13

')) +-- !query schema +struct13

):struct>>> +-- !query output +{[{1, 2}, {3, null}]} + + +-- !query +SELECT from_xml('

13

', schema_of_xml('

13

', map('excludeAttribute','true')), map('excludeAttribute','true')) +-- !query schema +struct13

):struct>> +-- !query output +{[1, 3]} + + +-- !query +SELECT CASE WHEN 1 = 2 THEN schema_of_xml('

') ELSE 'ok' END +-- !query schema +struct) ELSE ok END:string> +-- !query output +ok + + +-- !query +SELECT IF(false, schema_of_xml('

'), 'ok') +-- !query schema +struct<(IF(false, schema_of_xml(

), ok)):string> +-- !query output +ok + + +-- !query +SELECT COALESCE('ok', schema_of_xml('

')) +-- !query schema +struct)):string> +-- !query output +ok + + +-- !query +SELECT * FROM range(2) WHERE id = 5 AND schema_of_xml('

') = 'x' +-- !query schema +struct +-- !query output + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_calendar.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_calendar.sql.out new file mode 100644 index 000000000..f0f700ad1 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_calendar.sql.out @@ -0,0 +1,686 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 12)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 1, 12)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), make_interval(0, 0, 0, 0, 0, 0, 1)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), make_interval(0, -1)) +-- !query schema +struct> +-- !query output +[2018-05-31, 2018-04-30, 2018-03-31, 2018-02-28, 2018-01-31] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, -1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 months + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 0)) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval()) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1, 0, -2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-30, 2018-02-25] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), cast('1 month' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), cast('1 month 2 days' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast('1 day' as interval)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), make_interval(0, 1))) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 00:00:00, 2018-03-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 03:00:00, 2018-03-05 06:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', make_interval(0, 0, 0, 0, 6)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', make_interval(0, 0, 0, 0, 0, 0, 0.5)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.5, 2018-01-01 00:00:01, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1)) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval(0, -1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 months + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', make_interval()) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', make_interval(0, 1, 0, -2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-30 00:00:00, 2018-02-25 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', make_interval(0, -1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-03-02 00:00:00, 2018-02-04 00:00:00, 2018-01-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', make_interval(0, 1, 0, 2, 3)) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 03:00:00, 2018-03-05 06:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', make_interval()) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', make_interval(0, 1)) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 01:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 01:00:00, 2018-03-12 02:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', make_interval(0, 1)) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', make_interval(0, 0, 0, 0, 24)) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-04 23:00:00, 2018-11-05 23:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-11-04 01:30:00, 2018-11-05 01:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', make_interval(0, 0, 0, 1, 12)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 13:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', make_interval(0, 0, 0, -1)) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), make_interval(0, 0, 0, 1)) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days 3 hours'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT typeof(interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), make_interval(0, 1, 0, 2)) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.legacy.interval.enabled=true +-- !query schema +struct +-- !query output +spark.sql.legacy.interval.enabled true + + +-- !query +SELECT typeof(interval 1 month 2 days) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT typeof(interval 1 month) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT typeof(interval 1 day) +-- !query schema +struct +-- !query output +interval + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-03, 2018-03-05] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-03 00:00:00, 2018-03-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval'} +message: sequence step must be an interval of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 months + + +-- !query +SET spark.sql.legacy.interval.enabled=false +-- !query schema +struct +-- !query output +spark.sql.legacy.interval.enabled false + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_dates.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_dates.sql.out new file mode 100644 index 000000000..2661a7484 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_dates.sql.out @@ -0,0 +1,781 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2020-01-01'), interval '1' year) +-- !query schema +struct> +-- !query output +[2018-01-01, 2019-01-01, 2020-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1 0' day to hour) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '2 0:0:0' day to second) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-03, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 12 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-03'), interval 1 hour) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-04-05'), interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-05'), to_date('2018-01-01')) +-- !query schema +struct> +-- !query output +[2018-01-05, 2018-01-04, 2018-01-03, 2018-01-02, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01')) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-01, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' month) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-01, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval '-1' day) +-- !query schema +struct> +-- !query output +[2018-03-01, 2018-02-28, 2018-02-27, 2018-02-26, 2018-02-25, 2018-02-24, 2018-02-23, 2018-02-22, 2018-02-21, 2018-02-20, 2018-02-19, 2018-02-18, 2018-02-17, 2018-02-16, 2018-02-15, 2018-02-14, 2018-02-13, 2018-02-12, 2018-02-11, 2018-02-10, 2018-02-09, 2018-02-08, 2018-02-07, 2018-02-06, 2018-02-05, 2018-02-04, 2018-02-03, 2018-02-02, 2018-02-01, 2018-01-31, 2018-01-30, 2018-01-29, 2018-01-28, 2018-01-27, 2018-01-26, 2018-01-25, 2018-01-24, 2018-01-23, 2018-01-22, 2018-01-21, 2018-01-20, 2018-01-19, 2018-01-18, 2018-01-17, 2018-01-16, 2018-01-15, 2018-01-14, 2018-01-13, 2018-01-12, 2018-01-11, 2018-01-10, 2018-01-09, 2018-01-08, 2018-01-07, 2018-01-06, 2018-01-05, 2018-01-04, 2018-01-03, 2018-01-02, 2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 17532 to 17536 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-01'), interval 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2020-01-31'), to_date('2020-05-31'), interval 1 month) +-- !query schema +struct> +-- !query output +[2020-01-31, 2020-02-29, 2020-03-31, 2020-04-30, 2020-05-31] + + +-- !query +SELECT sequence(to_date('2020-02-29'), to_date('2024-03-01'), interval '1' year) +-- !query schema +struct> +-- !query output +[2020-02-29, 2021-02-28, 2022-02-28, 2023-02-28, 2024-02-29] + + +-- !query +SELECT sequence(to_date('2018-05-31'), to_date('2018-01-01'), interval -1 month) +-- !query schema +struct> +-- !query output +[2018-05-31, 2018-04-30, 2018-03-31, 2018-02-28, 2018-01-31] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), NULL)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), NULL)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(NULL, to_date('2018-01-05'), interval 1 day) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), NULL, interval 1 day) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(cast(NULL as date), cast(NULL as date)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval day)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), cast(NULL as interval month)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(to_date('2018-01-01'), to_date('2018-03-01'))) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(to_date('0001-01-01'), to_date('0001-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[0001-01-01, 0001-02-01, 0001-03-01] + + +-- !query +SELECT sequence(to_date('9999-11-01'), to_date('9999-12-31'), interval 1 month) +-- !query schema +struct> +-- !query output +[9999-11-01, 9999-12-01] + + +-- !query +SELECT sequence(to_date('1582-10-01'), to_date('1582-10-20'), interval 5 days) +-- !query schema +struct> +-- !query output +[1582-10-01, 1582-10-06, 1582-10-11, 1582-10-16] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 12 hours) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day 1 microsecond) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 86400000000 microseconds) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT size(sequence(to_date('2000-01-01'), to_date('2000-12-31'))) +-- !query schema +struct +-- !query output +366 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1 day') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1 day)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1 day)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), 5, interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), 5, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), 5, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(to_date('2018-01-01')) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '1', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 1. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(date '2018-01-01', timestamp '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(date '2018-01-01', timestamp_ntz '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' year to month) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: INVALID_INTERVAL_FORMAT.UNMATCHED_FORMAT_STRING +sqlState: 22006 +messageParameters: {'input': '1', 'intervalStr': 'year-month', 'supportedFormat': "`[+|-]y-m`, `INTERVAL [+|-]'[+|-]y-m' YEAR TO MONTH`", 'typeName': 'interval year to month'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '10' day) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 week) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-08, 2018-01-15, 2018-01-22, 2018-01-29, 2018-02-05, 2018-02-12, 2018-02-19, 2018-02-26] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-02-01'), interval 1 week) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-08, 2018-01-15, 2018-01-22, 2018-01-29] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month, 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 quarter) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: PARSE_SYNTAX_ERROR +sqlState: 42601 +messageParameters: {'error': "'quarter'", 'hint': ''} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 3 months) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-04-01, 2018-07-01, 2018-10-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 1 year 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2020-12-01'), interval 1 year 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2019-02-01, 2020-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1 1' year to month) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: INVALID_INTERVAL_FORMAT.UNMATCHED_FORMAT_STRING +sqlState: 22006 +messageParameters: {'input': '1 1', 'intervalStr': 'year-month', 'supportedFormat': "`[+|-]y-m`, `INTERVAL [+|-]'[+|-]y-m' YEAR TO MONTH`", 'typeName': 'interval year to month'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-12-01'), interval 0 months 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 0 months 1 day'} +message: + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-31'), to_date('2018-06-30'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31, 2018-06-30] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-02-01, 2018-03-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05')) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), '1') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), to_date(2018-01-05), 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), to_date(2018-01-05), 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(to_date(2018-01-01), 2018-01-05, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(to_date(2018-01-01), 2018-01-05, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SELECT sequence(to_date('2018-01-01'), '2018-01-05', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01, 2018-01-02, 2018-01-03, 2018-01-04, 2018-01-05] + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_errors.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_errors.sql.out new file mode 100644 index 000000000..783e54c75 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_errors.sql.out @@ -0,0 +1,661 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval '0' month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval '0' day) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval day to second'} +message: sequence step must be an interval day to second of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval -1 day) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 17532 to 17536 by -1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by -3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514851200000000 to 1514764800000000 by 3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 month 0 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 0 month 0 day'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-02 00:00:00', interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-03-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval -1 month 2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month -2 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-02'), interval 1 month 0 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 0 days'} +message: + + +-- !query +SELECT sequence(to_date('2018-03-02'), to_date('2018-01-01'), interval -1 month -2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval -1 month -2 days'} +message: + + +-- !query +SELECT size(sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day)) +-- !query schema +struct +-- !query output +5 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT size(sequence(to_date('0001-01-01'), to_date('9999-12-31'), interval 1 day)) +-- !query schema +struct +-- !query output +3652059 + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '315537811200000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 315537811200000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 millisecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '315537811200001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 315537811200001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT size(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:05', interval 1 microsecond)) +-- !query schema +struct +-- !query output +5000001 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-02-01 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2678400000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2678400000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483647', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483647 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1L, 2147483648L) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483648', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483648 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483633) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483633', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483633 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(-2147483648, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '4294967296', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 4294967296 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(-2147483648, 2147483647, 2147483647) +-- !query schema +struct> +-- !query output +[-2147483648, -1, 2147483646] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 106751991 days) +-- !query schema +struct> +-- !query output +[2018-01-01] + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 9999999999 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION +sqlState: 22006 +messageParameters: {'input': ' 9999999999 days'} +message: [INVALID_INTERVAL_FORMAT.ARITHMETIC_EXCEPTION] Error parsing ' 9999999999 days' to interval. Please ensure that the value provided is in a valid format for defining an interval. You can reference the documentation for the correct format. Uncaught arithmetic exception while parsing ' 9999999999 days'. SQLSTATE: 22006 + + +-- !query +CREATE OR REPLACE TEMPORARY VIEW sq AS SELECT * FROM VALUES + (1, to_date('2018-01-01'), to_date('2018-03-01'), interval 1 month), + (2, to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month), + (3, to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month), + (4, to_date('2018-01-01'), NULL, interval 1 month), + (5, to_date('2018-01-31'), to_date('2018-05-31'), interval 1 month) AS t(id, a, b, s) +-- !query schema +struct<> +-- !query output + + +-- !query +SELECT id, sequence(a, b, s) FROM sq WHERE id IN (1, 4, 5) ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id, sequence(a, b, s) FROM sq ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) ELSE array() END FROM sq ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 [] +3 [] +4 [] +5 [] + + +-- !query +SELECT id, IF(id = 1, sequence(a, b, s), NULL) FROM sq ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 NULL +3 NULL +4 NULL +5 NULL + + +-- !query +SELECT id, COALESCE(sequence(a, b, s), array(a)) FROM sq WHERE id = 1 OR id = 4 ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +4 [2018-01-01] + + +-- !query +SELECT id, CASE WHEN s > interval 0 month THEN sequence(a, b, s) END FROM sq WHERE id <> 3 ORDER BY id +-- !query schema +struct INTERVAL '0' MONTH) THEN sequence(a, b, s) END:array> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +2 NULL +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id, CASE WHEN a <= b THEN sequence(a, b, s) END FROM sq WHERE id <> 2 ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01, 2018-02-01, 2018-03-01] +3 NULL +4 NULL +5 [2018-01-31, 2018-02-28, 2018-03-31, 2018-04-30, 2018-05-31] + + +-- !query +SELECT id FROM sq WHERE id = 1 AND size(sequence(a, b, s)) = 3 +-- !query schema +struct +-- !query output +1 + + +-- !query +SELECT id FROM sq WHERE id <> 2 AND size(sequence(a, b, s)) = 3 ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3243 +sqlState: None +messageParameters: {'start': '1519862400000000', 'step': '1', 'stop': '1514764800000000'} +message: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT id, size(sequence(a, b, s)) FROM sq WHERE id IN (1, 5) ORDER BY id +-- !query schema +struct +-- !query output +1 3 +5 5 + + +-- !query +CREATE OR REPLACE TEMPORARY VIEW sqt AS SELECT * FROM VALUES + (1, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour), + (2, timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 0 hour), + (3, timestamp '2018-01-01 03:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) AS t(id, a, b, s) +-- !query schema +struct<> +-- !query output + + +-- !query +SELECT id, sequence(a, b, s) FROM sqt WHERE id = 1 +-- !query schema +struct> +-- !query output +1 [2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] + + +-- !query +SELECT id, sequence(a, b, s) FROM sqt +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514775600000000 by 0 + + +-- !query +SELECT id, CASE WHEN id = 1 THEN sequence(a, b, s) END FROM sqt ORDER BY id +-- !query schema +struct> +-- !query output +1 [2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] +2 NULL +3 NULL + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-03-01'), interval 0 month) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SELECT sequence(to_date('2018-03-01'), to_date('2018-01-01'), interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 0 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514851200000000 to 1514764800000000 by 3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-12-31 00:00:00', interval 1 microsecond) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '31449600000001', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 31449600000001 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT sequence(1, 2147483647) +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkRuntimeException +errorClass: COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER +sqlState: 54000 +messageParameters: {'functionName': '`sequence`', 'maxRoundedArrayLength': '2147483632', 'numberOfElements': '2147483647', 'parameter': '`count`'} +message: [COLLECTION_SIZE_LIMIT_EXCEEDED.PARAMETER] Can't create array with 2147483647 elements which exceeding the array size limit 2147483632, the value of parameter(s) `count` in the function `sequence` is invalid. SQLSTATE: 54000 + + +-- !query +SELECT id, sequence(a, b, s) FROM sq ORDER BY id +-- !query schema +struct<> +-- !query output +org.apache.spark.SparkIllegalArgumentException +errorClass: _LEGACY_ERROR_TEMP_3242 +sqlState: None +messageParameters: {'intervalType': 'interval year to month'} +message: sequence step must be an interval year to month of day granularity if start and end values are dates + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '4', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 4. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence(true, false) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(true, false)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(true, false)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(1.5, 3.5) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(1.5, 3.5)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(1.5, 3.5)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence('a', 'b', interval 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(a, b, INTERVAL \'1\' DAY)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(a, b, INTERVAL '1' DAY)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(to_date('2018-01-01'), to_date('2018-01-05'), interval 1 day, 1, 2) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '5', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 5. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + + +-- !query +SELECT sequence() +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.AnalysisException +errorClass: WRONG_NUM_ARGS.WITHOUT_SUGGESTION +sqlState: 42605 +messageParameters: {'actualNum': '0', 'docroot': 'https://spark.apache.org/docs/latest', 'expectedNum': '[2, 3]', 'functionName': '`sequence`'} +message: [WRONG_NUM_ARGS.WITHOUT_SUGGESTION] The `sequence` requires [2, 3] parameters but the actual number is 0. Please, refer to 'https://spark.apache.org/docs/latest/sql-ref-functions.html' for a fix. SQLSTATE: 42605; line 1 pos 7 + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_timestamps.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_timestamps.sql.out new file mode 100644 index 000000000..7b27827e2 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_timestamps.sql.out @@ -0,0 +1,732 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0-1' year to month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2020-01-01 00:00:00', interval '1' year) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2019-01-01 00:00:00, 2020-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 01:00:00', interval '0 0:15:0' day to second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:15:00, 2018-01-01 00:30:00, 2018-01-01 00:45:00, 2018-01-01 01:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:02', interval 500 milliseconds) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.5, 2018-01-01 00:00:01, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:01', interval 250000 microseconds) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:00.25, 2018-01-01 00:00:00.5, 2018-01-01 00:00:00.75, 2018-01-01 00:00:01] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00, 2018-01-04 00:00:00, 2018-01-05 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-04-05 00:00:00', interval 1 month 2 days 3 hours) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days 3 hours'} +message: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-01 00:00:03\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-01 00:00:03', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:03', timestamp '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '-1' month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval -6 hours) +-- !query schema +struct> +-- !query output +[2018-01-02 00:00:00, 2018-01-01 18:00:00, 2018-01-01 12:00:00, 2018-01-01 06:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-02 00:00:00', timestamp '2018-01-01 00:00:00', interval '-6' hour) +-- !query schema +struct> +-- !query output +[2018-01-02 00:00:00, 2018-01-01 18:00:00, 2018-01-01 12:00:00, 2018-01-01 06:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-01 00:00:00', timestamp '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval -1 hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by -3600000000 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval '0' month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '0' hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00', interval '0' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2020-02-29 10:00:00', timestamp '2024-03-01 10:00:00', interval '1' year) +-- !query schema +struct> +-- !query output +[2020-02-29 10:00:00, 2021-02-28 10:00:00, 2022-02-28 10:00:00, 2023-02-28 10:00:00, 2024-02-29 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-05-31 10:00:00', timestamp '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-05-31 10:00:00, 2018-04-30 10:00:00, 2018-03-31 10:00:00, 2018-02-28 10:00:00, 2018-01-31 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', NULL) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', NULL)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', NULL)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(NULL, timestamp '2018-01-02 00:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', NULL, interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(cast(NULL as timestamp), cast(NULL as timestamp)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', cast(NULL as interval day)) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval 1 hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 1 hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT typeof(sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '1' hour)) +-- !query schema +struct +-- !query output +array + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:00.000003') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00.5', timestamp '2018-01-01 00:00:03', interval 1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00.5, 2018-01-01 00:00:01.5, 2018-01-01 00:00:02.5] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', date '2018-01-03', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp_ntz '2018-01-03 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-02 00:00:00, 2018-01-03 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 3600)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 3600)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 3600L) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 3600)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 3600)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03', 1L) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-01 00:00:03\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-01 00:00:03', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1 hour') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 1 hour)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 1 hour)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', '2018-01-01 00:00:03', interval 1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 00:00:01, 2018-01-01 00:00:02, 2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp '0001-01-01 00:00:00', timestamp '0001-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[0001-01-01 00:00:00, 0001-02-01 00:00:00, 0001-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '9999-11-01 00:00:00', timestamp '9999-12-31 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[9999-11-01 00:00:00, 9999-12-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-04-05 00:00:00', interval 1 month 2 days) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 2 days'} +message: + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:03', timestamp_ntz '2018-01-01 00:00:00', interval -1 second) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:03, 2018-01-01 00:00:02, 2018-01-01 00:00:01, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval -1 month) +-- !query schema +struct> +-- !query output +[2018-03-01 00:00:00, 2018-02-01 00:00:00, 2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00', interval 1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1519862400000000 to 1514764800000000 by 1 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-02 00:00:00', interval '0' hour) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1514851200000000 by 0 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-31 10:00:00', timestamp_ntz '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', NULL, interval 1 hour) +-- !query schema +struct> +-- !query output +NULL + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-01-01 00:00:00') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-31 10:00:00', timestamp '2018-06-30 10:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-31 10:00:00, 2018-02-28 10:00:00, 2018-03-31 10:00:00, 2018-04-30 10:00:00, 2018-05-31 10:00:00, 2018-06-30 10:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', interval '6' hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 06:00:00, 2018-01-01 12:00:00, 2018-01-01 18:00:00, 2018-01-02 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 00:00:03') +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', 0) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 0)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 0)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 0 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by 0 + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval -1 month) +-- !query schema +struct<> +-- !query output +java.lang.IllegalArgumentException +message: requirement failed: Illegal sequence boundaries: 1514764800000000 to 1519862400000000 by -1 + + +-- !query +SELECT sequence(timestamp_ntz '2018-01-01 00:00:00', timestamp_ntz '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-02 00:00:00', '1') +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-01-01 00:00:00\', TIMESTAMP \'2018-01-02 00:00:00\', 1)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-01-01 00:00:00', TIMESTAMP '2018-01-02 00:00:00', 1)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + diff --git a/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_tz.sql.out b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_tz.sql.out new file mode 100644 index 000000000..8867461e0 --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/results/spark-4.3.0/sequence_tz.sql.out @@ -0,0 +1,489 @@ +-- Generated by run_oracle.py against Spark 4.3.0 + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1 0:0:0' day to second) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 12:00:00', timestamp '2018-03-12 12:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-03-10 12:00:00, 2018-03-11 12:00:00, 2018-03-12 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 00:00:00', timestamp '2018-03-11 05:00:00', interval '1' hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 02:30:00', timestamp '2018-03-13 02:30:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 03:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-11 02:30:00', timestamp '2018-03-12 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-11 03:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-02-11 02:30:00', timestamp '2018-04-11 02:30:00', interval '1' month) +-- !query schema +struct> +-- !query output +[2018-02-11 02:30:00, 2018-03-11 03:30:00, 2018-04-11 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 01:00:00, 2018-03-12 02:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 month 1 day) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.parser.ParseException +errorClass: _LEGACY_ERROR_TEMP_0029 +sqlState: None +messageParameters: {'literal': 'interval 1 month 1 day'} +message: + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00') +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', 86400) +-- !query schema +struct<> +-- !query output +org.apache.spark.sql.catalyst.ExtendedAnalysisException +errorClass: DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES +sqlState: 42K09 +messageParameters: {'functionName': '`sequence`', 'otherStartType': '"INTEGRAL"', 'sqlExpr': '"sequence(TIMESTAMP \'2018-03-10 00:00:00\', TIMESTAMP \'2018-03-13 00:00:00\', 86400)"', 'startType': '("TIMESTAMP" or "TIMESTAMP_NTZ" or "DATE")', 'stepType': '("INTERVAL" or "INTERVAL YEAR TO MONTH" or "INTERVAL DAY TO SECOND")'} +message: [DATATYPE_MISMATCH.SEQUENCE_WRONG_INPUT_TYPES] Cannot resolve "sequence(TIMESTAMP '2018-03-10 00:00:00', TIMESTAMP '2018-03-13 00:00:00', 86400)" due to data type mismatch: `sequence` uses the wrong parameter type. The parameter type must conform to: + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -1 day) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval '-1' day) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-13 00:00:00', timestamp '2018-03-10 00:00:00', interval -24 hours) +-- !query schema +struct> +-- !query output +[2018-03-13 00:00:00, 2018-03-12 00:00:00, 2018-03-11 00:00:00, 2018-03-10 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-12 02:30:00', timestamp '2018-03-10 02:30:00', interval -1 day) +-- !query schema +struct> +-- !query output +[2018-03-12 02:30:00, 2018-03-11 03:30:00, 2018-03-10 02:30:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 00:00:00', timestamp '2018-11-06 00:00:00', interval '24' hour) +-- !query schema +struct> +-- !query output +[2018-11-03 00:00:00, 2018-11-04 00:00:00, 2018-11-05 00:00:00, 2018-11-06 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-03 12:00:00, 2018-11-04 12:00:00, 2018-11-05 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-03 12:00:00', timestamp '2018-11-05 12:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-11-03 12:00:00, 2018-11-04 12:00:00, 2018-11-05 12:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 00:00:00', timestamp '2018-11-04 04:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-11-04 00:00:00, 2018-11-04 01:00:00, 2018-11-04 01:00:00, 2018-11-04 02:00:00, 2018-11-04 03:00:00, 2018-11-04 04:00:00] + + +-- !query +SELECT sequence(timestamp '2018-11-04 01:30:00', timestamp '2018-11-05 01:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-11-04 01:30:00, 2018-11-05 01:30:00] + + +-- !query +SELECT sequence(timestamp '2018-10-04 01:30:00', timestamp '2018-12-04 01:30:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-10-04 01:30:00, 2018-11-04 01:30:00, 2018-12-04 01:30:00] + + +-- !query +SELECT sequence(to_timestamp('2018-03-11 09:00:00Z'), to_timestamp('2018-03-11 12:00:00Z'), interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 01:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(to_timestamp('2018-03-10 08:00:00Z'), to_timestamp('2018-03-12 08:00:00Z'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13')) +-- !query schema +struct> +-- !query output +[2018-03-10, 2018-03-11, 2018-03-12, 2018-03-13] + + +-- !query +SELECT sequence(to_date('2018-03-10'), to_date('2018-03-13'), interval 1 month) +-- !query schema +struct> +-- !query output +[2018-03-10] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 00:00:00', timestamp_ntz '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-11 00:00:00', timestamp_ntz '2018-03-11 05:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-03-11 00:00:00, 2018-03-11 01:00:00, 2018-03-11 02:00:00, 2018-03-11 03:00:00, 2018-03-11 04:00:00, 2018-03-11 05:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-11-04 00:00:00', timestamp_ntz '2018-11-04 04:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-11-04 00:00:00, 2018-11-04 01:00:00, 2018-11-04 02:00:00, 2018-11-04 03:00:00, 2018-11-04 04:00:00] + + +-- !query +SELECT sequence(timestamp_ntz '2018-03-10 02:30:00', timestamp_ntz '2018-03-13 02:30:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 02:30:00, 2018-03-11 02:30:00, 2018-03-12 02:30:00, 2018-03-13 02:30:00] + + +-- !query +SET spark.sql.session.timeZone=Australia/Lord_Howe +-- !query schema +struct +-- !query output +spark.sql.session.timeZone Australia/Lord_Howe + + +-- !query +SELECT sequence(timestamp '2018-04-01 00:00:00', timestamp '2018-04-02 00:00:00', interval 6 hours) +-- !query schema +struct> +-- !query output +[2018-04-01 00:00:00, 2018-04-01 05:30:00, 2018-04-01 11:30:00, 2018-04-01 17:30:00, 2018-04-01 23:30:00] + + +-- !query +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-10-06 00:00:00, 2018-10-07 00:00:00, 2018-10-08 00:00:00, 2018-10-09 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-10-06 00:00:00', timestamp '2018-10-09 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-10-06 00:00:00, 2018-10-07 00:00:00, 2018-10-08 00:00:00, 2018-10-09 00:00:00] + + +-- !query +SET spark.sql.session.timeZone=Asia/Kolkata +-- !query schema +struct +-- !query output +spark.sql.session.timeZone Asia/Kolkata + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-01-01 03:00:00', interval 1 hour) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-01-01 01:00:00, 2018-01-01 02:00:00, 2018-01-01 03:00:00] + + +-- !query +SELECT sequence(timestamp '2018-01-01 00:00:00', timestamp '2018-03-01 00:00:00', interval 1 month) +-- !query schema +struct> +-- !query output +[2018-01-01 00:00:00, 2018-02-01 00:00:00, 2018-03-01 00:00:00] + + +-- !query +SET spark.sql.session.timeZone=America/Los_Angeles +-- !query schema +struct +-- !query output +spark.sql.session.timeZone America/Los_Angeles + + +-- !query +SET spark.sql.ansi.enabled=false +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled false + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 1 day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval 24 hours) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SELECT sequence(timestamp '2018-03-10 00:00:00', timestamp '2018-03-13 00:00:00', interval '1' day) +-- !query schema +struct> +-- !query output +[2018-03-10 00:00:00, 2018-03-11 00:00:00, 2018-03-12 00:00:00, 2018-03-13 00:00:00] + + +-- !query +SET spark.sql.ansi.enabled=true +-- !query schema +struct +-- !query output +spark.sql.ansi.enabled true + + +-- !query +SET spark.sql.session.timeZone=UTC +-- !query schema +struct +-- !query output +spark.sql.session.timeZone UTC + diff --git a/tests/spark-golden/functions/sequence_xml/run.sh b/tests/spark-golden/functions/sequence_xml/run.sh new file mode 100755 index 000000000..3886dfd7b --- /dev/null +++ b/tests/spark-golden/functions/sequence_xml/run.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: Apache-2.0 +# Usage: run.sh [name]. Regenerates results/spark-/*.out in a throwaway container. +set -e +V=$1 +ONLY=${2:-*} +HERE=$(cd "$(dirname "$0")" && pwd) +FN=$(dirname "$HERE") +N=krishiv-s7sql456-oracle-$V +mkdir -p "$HERE/results/spark-$V" +docker run --rm --name "$N" --user root -v "$FN":/g -w /g apache/spark:$V /bin/bash -c ' +failed=0 +for f in /g/sequence_xml/inputs/'"$ONLY"'.sql; do + b=$(basename $f) + /opt/spark/bin/spark-submit --conf spark.ui.enabled=false /g/run_oracle.py $f /g/sequence_xml/results/spark-'"$V"'/$b.out >/dev/null 2>&1 || { echo FAIL $b; failed=1; } +done +exit $failed'