Helper function to get default value for NULL numeric/scalar columns
| 73 | |
| 74 | // Helper function to get default value for NULL numeric/scalar columns |
| 75 | nd::array get_default_value_for_null(Oid base_typeid) |
| 76 | { |
| 77 | switch (base_typeid) { |
| 78 | case INT2OID: |
| 79 | return nd::adapt(static_cast<int16_t>(0)); |
| 80 | case INT4OID: |
| 81 | case DATEOID: |
| 82 | return nd::adapt(static_cast<int32_t>(0)); |
| 83 | case TIMEOID: |
| 84 | case TIMESTAMPOID: |
| 85 | case TIMESTAMPTZOID: |
| 86 | case INT8OID: |
| 87 | return nd::adapt(static_cast<int64_t>(0)); |
| 88 | case FLOAT4OID: |
| 89 | return nd::adapt(static_cast<float>(0.0)); |
| 90 | case NUMERICOID: |
| 91 | case FLOAT8OID: |
| 92 | return nd::adapt(static_cast<double>(0.0)); |
| 93 | case BOOLOID: |
| 94 | return nd::adapt(false); |
| 95 | default: |
| 96 | // For non-numeric types, use nd::none |
| 97 | return nd::none(nd::dtype::unknown, 0); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void convert_pg_to_nd(const pg::table_data& table_data, |
| 102 | const std::vector<Datum>& values, |
no test coverage detected