Skip to content

Commit e06de11

Browse files
committed
some todos
1 parent 0d34f4d commit e06de11

File tree

8 files changed

+284
-37
lines changed

8 files changed

+284
-37
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ There is currently only one GUC parameter to enable/disable the `pg_parquet`:
423423
| `time` | INT64 | TIME_MICROS |
424424
| `timetz`(3) | INT64 | TIME_MICROS |
425425
| `geometry`(4) | BYTE_ARRAY | |
426+
| `geography`(4) | BYTE_ARRAY | |
426427

427428
### Nested Types
428429
| PostgreSQL Type | Parquet Physical Type | Logical Type |
@@ -440,7 +441,7 @@ There is currently only one GUC parameter to enable/disable the `pg_parquet`:
440441
> * `numeric` is allowed by Postgres. (precision and scale not specified). These are represented by a default precision (38) and scale (9) instead of writing them as string. You get runtime error if your table tries to read or write a numeric value which is not allowed by the default precision and scale (29 integral digits before decimal point, 9 digits after decimal point).
441442
> - (2) The `date` type is represented according to `Unix epoch` when writing to Parquet files. It is converted back according to `PostgreSQL epoch` when reading from Parquet files.
442443
> - (3) The `timestamptz` and `timetz` types are adjusted to `UTC` when writing to Parquet files. They are converted back with `UTC` timezone when reading from Parquet files.
443-
> - (4) The `geometry` type is represented as `BYTE_ARRAY` encoded as `WKB`, specified by [geoparquet spec](https://geoparquet.org/releases/v1.1.0/), when `postgis` extension is created. Otherwise, it is represented as `BYTE_ARRAY` with `STRING` logical type.
444+
> - (4) The `geometry` and `geography` type is represented as `BYTE_ARRAY` encoded as `WKB`, specified by [geoparquet spec](https://geoparquet.org/releases/v1.1.0/), when `postgis` extension is created. Otherwise, it is represented as `BYTE_ARRAY` with `STRING` logical type. Orientation and edges metadata are written when `postgis_sfcgal` extension is created.
444445
> - (5) `crunchy_map` is dependent on functionality provided by [Crunchy Bridge](https://www.crunchydata.com/products/crunchy-bridge). The `crunchy_map` type is represented as `GROUP` with `MAP` logical type when `crunchy_map` extension is created. Otherwise, it is represented as `BYTE_ARRAY` with `STRING` logical type.
445446
446447
> [!WARNING]

src/parquet_copy_hook/copy_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::{
2424
parquet_writer::{DEFAULT_ROW_GROUP_SIZE, DEFAULT_ROW_GROUP_SIZE_BYTES},
2525
uri_utils::ParsedUriInfo,
2626
},
27-
pgrx_utils::extension_exists,
27+
pgrx_utils::is_extension_created,
2828
};
2929

3030
use self::field_ids::FieldIds;
@@ -483,12 +483,12 @@ fn is_copy_parquet_stmt(p_stmt: &PgBox<PlannedStmt>, copy_from: bool) -> bool {
483483
// this is why we check them after the uri checks
484484

485485
// crunchy_query_engine should not be created
486-
if extension_exists("crunchy_query_engine") {
486+
if is_extension_created("crunchy_query_engine") {
487487
return false;
488488
}
489489

490490
// pg_parquet should be created
491-
if !extension_exists("pg_parquet") {
491+
if !is_extension_created("pg_parquet") {
492492
ereport!(
493493
PgLogLevel::WARNING,
494494
PgSqlErrorCode::ERRCODE_WARNING,

src/pgrx_tests/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ pub(crate) fn timetz_array_to_utc_time_array(
358358
)
359359
}
360360

361-
pub(crate) fn extension_exists(extension_name: &str) -> bool {
361+
pub(crate) fn is_extension_available(extension_name: &str) -> bool {
362362
let quoted_extension = spi::quote_literal(extension_name);
363363
let query =
364364
format!("select count(*) = 1 from pg_available_extensions where name = {quoted_extension}");
@@ -375,7 +375,7 @@ pub(crate) fn write_record_batch_to_parquet(schema: SchemaRef, record_batch: Rec
375375
}
376376

377377
pub(crate) fn create_crunchy_map_type(key_type: &str, val_type: &str) -> String {
378-
assert!(extension_exists("crunchy_map"));
378+
assert!(is_extension_available("crunchy_map"));
379379

380380
let command = format!("SELECT crunchy_map.create('{key_type}','{val_type}')::text;",);
381381
Spi::get_one(&command).unwrap().unwrap()

src/pgrx_tests/copy_from_coerce.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod tests {
55
use std::vec;
66

77
use crate::pgrx_tests::common::{
8-
extension_exists, write_record_batch_to_parquet, LOCAL_TEST_FILE_PATH,
8+
is_extension_available, write_record_batch_to_parquet, LOCAL_TEST_FILE_PATH,
99
};
1010
use crate::type_compat::pg_arrow_type_conversions::{
1111
date_to_i32, time_to_i64, timestamp_to_i64, timestamptz_to_i64, timetz_to_i64,
@@ -886,7 +886,7 @@ mod tests {
886886
#[pg_test]
887887
fn test_coerce_map_types() {
888888
// Skip the test if crunchy_map extension is not available
889-
if !extension_exists("crunchy_map") {
889+
if !is_extension_available("crunchy_map") {
890890
return;
891891
}
892892

@@ -946,7 +946,7 @@ mod tests {
946946
#[pg_test]
947947
fn test_coerce_list_of_map() {
948948
// Skip the test if crunchy_map extension is not available
949-
if !extension_exists("crunchy_map") {
949+
if !is_extension_available("crunchy_map") {
950950
return;
951951
}
952952

src/pgrx_tests/copy_options.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ mod tests {
66

77
use crate::{
88
pgrx_tests::common::{
9-
create_crunchy_map_type, extension_exists, CopyOptionValue, FileCleanup, TestTable,
10-
LOCAL_TEST_FILE_PATH,
9+
create_crunchy_map_type, is_extension_available, CopyOptionValue, FileCleanup,
10+
TestTable, LOCAL_TEST_FILE_PATH,
1111
},
1212
PgParquetCompression,
1313
};
@@ -799,7 +799,7 @@ mod tests {
799799
#[pg_test]
800800
fn test_auto_field_ids_with_map() {
801801
// Skip the test if crunchy_map extension is not available
802-
if !extension_exists("crunchy_map") {
802+
if !is_extension_available("crunchy_map") {
803803
return;
804804
}
805805

@@ -891,7 +891,7 @@ mod tests {
891891
#[pg_test]
892892
fn test_explicit_field_ids_with_map() {
893893
// Skip the test if crunchy_map extension is not available
894-
if !extension_exists("crunchy_map") {
894+
if !is_extension_available("crunchy_map") {
895895
return;
896896
}
897897

0 commit comments

Comments
 (0)