Skip to content

Commit

Permalink
chore: tmp disable geometry test
Browse files Browse the repository at this point in the history
  • Loading branch information
everpcpc committed Apr 23, 2024
1 parent 33bec1f commit f30541c
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cli/tests/00-base.result
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Asia/Shanghai
NULL {'k1':'v1','k2':'v2'} (2,NULL)
1 NULL 1 ab
NULL v1 2 NULL
{'k1':'v1','k2':'v2'} [6162,78797A] ('[1,2]','SRID=4326;POINT(1 2)','2024-04-10')
{'k1':'v1','k2':'v2'} [6162,78797A] ('[1,2]','2024-04-10')
bye
2 changes: 1 addition & 1 deletion cli/tests/00-base.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ insert into test_nested values([1,2,3], null, (1, 'ab')), (null, {'k1':'v1', 'k2
select * from test_nested;
select a[1], b['k1'], c:x, c:y from test_nested;

select {'k1':'v1','k2':'v2'}, [to_binary('ab'), to_binary('xyz')], (parse_json('[1,2]'), st_geometryfromwkt('SRID=4326;POINT(1.0 2.0)'), to_date('2024-04-10'));
select {'k1':'v1','k2':'v2'}, [to_binary('ab'), to_binary('xyz')], (parse_json('[1,2]'), to_date('2024-04-10'));

select 'bye';
drop table test;
Expand Down
16 changes: 0 additions & 16 deletions driver/tests/driver/select_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,3 @@ async fn select_sleep() {
}
assert_eq!(result, vec![0]);
}

// #[tokio::test]
// async fn select_bitmap_string() {
// let (conn, _) = prepare("select_bitmap_string").await;
// let mut rows = conn
// .query_iter("select build_bitmap([1,2,3,4,5,6]), 11::String")
// .await
// .unwrap();
// let mut result = vec![];
// while let Some(row) = rows.next().await {
// let row: (String, String) = row.unwrap().try_into().unwrap();
// assert!(row.0.contains('\0'));
// result.push(row.1);
// }
// assert_eq!(result, vec!["11".to_string()]);
// }
35 changes: 32 additions & 3 deletions driver/tests/driver/select_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,51 @@ async fn select_tuple() {
assert_eq!(val1, ("[1,2]".to_string(), vec![1, 2], true,));

let row2 = conn
.query_row("select (st_geometryfromwkt('SRID=4126;POINT(3.0 5.0)'), to_timestamp('2024-10-22 10:11:12'))")
.query_row("select (to_binary('xyz'), to_timestamp('2024-10-22 10:11:12'))")
.await
.unwrap()
.unwrap();
let (val2,): ((String, NaiveDateTime),) = row2.try_into().unwrap();
let (val2,): ((Vec<u8>, NaiveDateTime),) = row2.try_into().unwrap();
assert_eq!(
val2,
(
"SRID=4126;POINT(3 5)".to_string(),
vec![120, 121, 122],
DateTime::parse_from_rfc3339("2024-10-22T10:11:12Z")
.unwrap()
.naive_utc()
)
);
}

#[tokio::test]
async fn select_variant() {
todo!()
}

#[tokio::test]
async fn select_bitmap() {
todo!()
// let (conn, _) = prepare("select_bitmap_string").await;
// let mut rows = conn
// .query_iter("select build_bitmap([1,2,3,4,5,6]), 11::String")
// .await
// .unwrap();
// let mut result = vec![];
// while let Some(row) = rows.next().await {
// let row: (String, String) = row.unwrap().try_into().unwrap();
// assert!(row.0.contains('\0'));
// result.push(row.1);
// }
// assert_eq!(result, vec!["11".to_string()]);
}

#[tokio::test]
async fn select_geometry() {
// TODO: response type changed to json after
// https://github.com/datafuselabs/databend/pull/15214
todo!()
}

#[tokio::test]
async fn select_multiple_columns() {
let conn = prepare().await;
Expand Down
12 changes: 6 additions & 6 deletions sql/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,6 @@ impl From<std::io::Error> for Error {
}
}

impl From<std::str::Utf8Error> for Error {
fn from(e: std::str::Utf8Error) -> Self {
Error::Parsing(e.to_string())
}
}

impl From<glob::GlobError> for Error {
fn from(e: glob::GlobError) -> Self {
Error::IO(e.to_string())
Expand Down Expand Up @@ -165,6 +159,12 @@ impl From<arrow_schema::ArrowError> for Error {
}
}

impl From<std::str::Utf8Error> for Error {
fn from(e: std::str::Utf8Error) -> Self {
Error::Parsing(e.to_string())
}
}

impl From<std::string::FromUtf8Error> for Error {
fn from(e: std::string::FromUtf8Error) -> Self {
Error::Parsing(e.to_string())
Expand Down
4 changes: 2 additions & 2 deletions sql/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@ pub fn parse_decimal(text: &str, size: DecimalSize) -> Result<NumberValue> {

pub fn parse_geometry(raw_data: &[u8]) -> Result<String> {
let mut data = std::io::Cursor::new(raw_data);
let wkt = Ewkt::from_wkb(&mut data, WkbDialect::Ewkb);
wkt.map(|g| g.0).map_err(|e| e.into())
let wkt = Ewkt::from_wkb(&mut data, WkbDialect::Ewkb)?;
Ok(wkt.0)
}

struct ValueDecoder {}
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
volumes:
- ./data:/data
databend:
image: docker.io/datafuselabs/databend:nightly
image: docker.io/datafuselabs/databend
environment:
- QUERY_STORAGE_TYPE=s3
- AWS_S3_ENDPOINT=http://localhost:9000
Expand Down

0 comments on commit f30541c

Please sign in to comment.