Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand type support #24

Closed
2 tasks done
Mytherin opened this issue Apr 29, 2024 · 5 comments
Closed
2 tasks done

Expand type support #24

Mytherin opened this issue Apr 29, 2024 · 5 comments
Assignees

Comments

@Mytherin
Copy link
Collaborator

Mytherin commented Apr 29, 2024

  • Floating point
  • Decimals
@wuputah wuputah added this to the postgres-features milestone Apr 29, 2024
@wuputah
Copy link
Collaborator

wuputah commented May 13, 2024

suggestions for further expansion (can create additional github issues):

  • uuid
  • json and jsonb
  • arrays
  • fallback to varchar

@Mytherin
Copy link
Collaborator Author

Longer term goal:

  • Preserve Postgres types also in DuckDB
  • Add a way of calling Postgres functions from within DuckDB, directly on the preserved types
  • Ideally lazily/automatically register Postgres functions that DuckDB does not have inside DuckDB so they can be used (as a slower fallback)

@Tishj
Copy link
Collaborator

Tishj commented May 22, 2024

Longer term goal:

  • Preserve Postgres types also in DuckDB
  • Add a way of calling Postgres functions from within DuckDB, directly on the preserved types
  • Ideally lazily/automatically register Postgres functions that DuckDB does not have inside DuckDB so they can be used (as a slower fallback)

I'm already (ab)using our type system to convey information between bind and postgres->duckdb value conversion like this:

		if (typmod == -1 || precision < 0 || scale < 0 || precision > 38) {
			auto extra_type_info = duckdb::make_shared<NumericAsDouble>();
			return duckdb::LogicalType(duckdb::LogicalTypeId::DOUBLE, std::move(extra_type_info));
		}
		if (aux_info && dynamic_cast<NumericAsDouble *>(aux_info.get())) {
			// This NUMERIC could not be converted to a DECIMAL, convert it as DOUBLE instead
			auto numeric = DatumGetNumeric(value);
			auto numeric_var = FromNumeric(numeric);
			auto double_val = ConvertDecimal<double, DecimalConversionDouble>(numeric_var);
			Append<double>(result, double_val, offset);
		}

We can probably use a similar method to preserve the postgres types

@Mytherin
Copy link
Collaborator Author

Instead of falling back to VARCHAR, let's add a custom type (UnsupportedPostgresType) that triggers an error when it gets used.

@wuputah wuputah modified the milestones: postgres-features, 0.1.0 May 27, 2024
@wuputah
Copy link
Collaborator

wuputah commented May 31, 2024

this has been mostly addressed in #23; lets open a new issue for anything else we are looking to address

@wuputah wuputah closed this as completed May 31, 2024
@wuputah wuputah added this to pg_duckdb Aug 5, 2024
@wuputah wuputah moved this to Done in pg_duckdb Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

3 participants