diff --git a/src/Makefile b/src/Makefile index a0e7df78..c88bd5a2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -78,8 +78,18 @@ ifeq ($(HAS_PARQUET),yes) PGSTROM_FLAGS += -DHAS_PARQUET=1 PG_CXXFLAGS += $(shell pkgconf --cflags parquet) SHLIB_LINK += $(shell pkgconf --libs parquet) +# Add runtime library path +PARQUET_LIBDIR = $(shell pkgconf --variable=libdir parquet) +ifneq ($(PARQUET_LIBDIR),) +SHLIB_LINK += -Wl,-rpath,$(PARQUET_LIBDIR) +endif else SHLIB_LINK += $(shell pkgconf --libs arrow) +# Add runtime library path for Arrow +ARROW_LIBDIR = $(shell pkgconf --variable=libdir arrow) +ifneq ($(ARROW_LIBDIR),) +SHLIB_LINK += -Wl,-rpath,$(ARROW_LIBDIR) +endif endif endif diff --git a/src/arrow_meta.cpp b/src/arrow_meta.cpp index f1e9c562..e6840f8d 100644 --- a/src/arrow_meta.cpp +++ b/src/arrow_meta.cpp @@ -3223,7 +3223,26 @@ __readParquetMinMaxStats(ArrowFieldNode *field, std::string min_datum; std::string max_datum; - switch (stats->physical_type()) + if (!stats) + return; + + // Safely attempt to get physical_type + parquet::Type::type phys_type; + try { + phys_type = stats->physical_type(); + } catch (const std::exception& e) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Failed to get physical_type from Parquet statistics: %s", e.what()); +#endif + return; + } catch (...) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Unknown error getting physical_type from Parquet statistics"); +#endif + return; + } + + switch (phys_type) { case parquet::Type::BOOLEAN: { auto __stat = std::dynamic_pointer_cast(stats); @@ -3359,10 +3378,33 @@ __readParquetRowGroupMetadata(ArrowMessage *rbatch_message, field->length = col_meta->num_values(); if (stats) { - if (stats->HasNullCount()) - field->null_count = stats->null_count(); - if (stats->HasMinMax()) - __readParquetMinMaxStats(field, stats); + // Handle null count statistics + try { + if (stats->HasNullCount()) + field->null_count = stats->null_count(); + } catch (const std::exception& e) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Failed to access null count statistics: %s", e.what()); +#endif + } catch (...) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Unknown error accessing null count statistics"); +#endif + } + + // Handle min/max statistics separately + try { + if (stats->HasMinMax()) + __readParquetMinMaxStats(field, stats); + } catch (const std::exception& e) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Failed to access min/max statistics: %s", e.what()); +#endif + } catch (...) { +#ifdef PGSTROM_DEBUG + elog(DEBUG1, "Unknown error accessing min/max statistics"); +#endif + } } /* * Some additional Parquet specific attrobutes for dump only