Skip to content

Commit

Permalink
BigQuery fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Sep 26, 2023
1 parent 1da0cbf commit 4ebea8c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class BigqueryQuery extends BaseQuery {
templates.functions.DATETRUNC = 'DATETIME_TRUNC(CAST({{ args[1] }} AS DATETIME), {{ date_part }})';
templates.expressions.binary = '{% if op == \'%\' %}MOD({{ left }}, {{ right }}){% else %}({{ left }} {{ op }} {{ right }}){% endif %}';
templates.expressions.interval = 'INTERVAL {{ interval }}';
templates.expressions.extract = 'EXTRACT({% if date_part == \'DOW\' %}DAYOFWEEK{% else %}{{ date_part }}{% endif %} FROM {{ expr }})';
templates.expressions.extract = 'EXTRACT({% if date_part == \'DOW\' %}DAYOFWEEK{% elif date_part == \'DOY\' %}DAYOFYEAR{% else %}{{ date_part }}{% endif %} FROM {{ expr }})';

Check warning on line 155 in packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.js

View check run for this annotation

Codecov / codecov/patch

packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.js#L155

Added line #L155 was not covered by tests
return templates;
}
}
28 changes: 27 additions & 1 deletion rust/cubesql/cubesql/src/compile/engine/df/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use cubeclient::models::{V1LoadRequestQuery, V1LoadResult, V1LoadResultAnnotatio
pub use datafusion::{
arrow::{
array::{
ArrayRef, BooleanBuilder, Date32Builder, Float64Builder, Int64Builder, StringBuilder,
ArrayRef, BooleanBuilder, Date32Builder, Float64Builder, Int32Builder, Int64Builder,
StringBuilder,
},
datatypes::{DataType, SchemaRef},
error::{ArrowError, Result as ArrowResult},
Expand Down Expand Up @@ -896,6 +897,31 @@ pub fn transform_response<V: ValueObject>(
}
)
}
DataType::Int32 => {
build_column!(
DataType::Int32,
Int32Builder,
response,
field_name,

Check warning on line 905 in rust/cubesql/cubesql/src/compile/engine/df/scan.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubesql/src/compile/engine/df/scan.rs#L900-L905

Added lines #L900 - L905 were not covered by tests
{
(FieldValue::Number(number), builder) => builder.append_value(number.round() as i32)?,
(FieldValue::String(s), builder) => match s.parse::<i32>() {
Ok(v) => builder.append_value(v)?,
Err(error) => {
warn!(
"Unable to parse value as i32: {}",
error.to_string()

Check warning on line 913 in rust/cubesql/cubesql/src/compile/engine/df/scan.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubesql/src/compile/engine/df/scan.rs#L907-L913

Added lines #L907 - L913 were not covered by tests
);

builder.append_null()?

Check warning on line 916 in rust/cubesql/cubesql/src/compile/engine/df/scan.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubesql/src/compile/engine/df/scan.rs#L916

Added line #L916 was not covered by tests
}
},
},
{
(ScalarValue::Int32(v), builder) => builder.append_option(v.clone())?,

Check warning on line 921 in rust/cubesql/cubesql/src/compile/engine/df/scan.rs

View check run for this annotation

Codecov / codecov/patch

rust/cubesql/cubesql/src/compile/engine/df/scan.rs#L921

Added line #L921 was not covered by tests
}
)
}
DataType::Int64 => {
build_column!(
DataType::Int64,
Expand Down

0 comments on commit 4ebea8c

Please sign in to comment.