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

added postgres type-descriptor #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PrasannaIITM
Copy link

Link to issue: #142

@eyurtsev
Copy link
Owner

@PrasannaIITM Contribution very much appreciated!! Code is looking great! I left a question about matching postgres syntax

(
"```Postgres\n"
"\n"
"object: { // Object Description\n"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema looks like it's something between typescript and postgres. I don't know how much this stuff matters since it's really hard to know what the LLM will do.

I was originally thinking about getting the postgres type description to output either the CREATE TABLE or a markdown table that shows the column/types/description of the table.

What are your thoughts on this?

CREATE TABLE sample_table (
    id SERIAL PRIMARY KEY,
    text_field TEXT,
    text_array_field TEXT[],
    float_field FLOAT,
    integer_field INTEGER,
    integer_array_field INTEGER[],
    embedded_json_field JSONB,
    color_enum_field COLOR_ENUM
);

CREATE TYPE color_enum AS ENUM ('RED', 'GREEN', 'BLUE');

or else the output from running:

SELECT column_name, data_type FROM information_schema.columns WHERE table_name = '...';   

something of this sort:

 column_name |     data_type
-------------+-------------------
 id          | integer
 text_field  | text
 text_array_field | text[]
 float_field | double precision
 integer_field | integer
 integer_array_field | integer[]
 embedded_json_field | jsonb
 color_enum_field | color_enum

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eyurtsev You are right. I was still determining the exact syntax; the markdown syntax table looks correct. I will update my PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue with the above approach is displaying nested objects. What would be the correct way to display nested objects in the markdown table format?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay -- was away from my computer yesterday!

I think this type descriptor best coupled to the CSV encoder.

The CSV encoder will likely rely on a JSON field for encoding nested objects, and that can be represented using the JSON type in postgres https://www.postgresql.org/docs/current/datatype-json.html


In either representation we choose (i.e., either the markdown table or the CREATE TABLE representation), we'll need to include the description of the column. An extra column for description would work for markdown and SQL style comments for the CREATE TABLE representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants