graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

computed fields should be persisted via metadata

Open mikyoengine opened this issue 7 years ago • 4 comments

Computed fields can be added via the metadata api but they are not exported or persisted via the metadata.json file.

This is critical for reproducible dockerized deployments.

mikyoengine avatar Oct 31 '19 21:10 mikyoengine

@mikyoengine ~~This has been fixed in the latest release which is beta.9~~

tirumaraiselvan avatar Oct 31 '19 21:10 tirumaraiselvan

@tirumaraiselvan I updated to beta.9 and am still not seeing this feature (both the release notes and via the console).

In fact, the addition of computed fields seems to break the metadata import. Steps to reproduce:

  1. Add a computed field via the metadata api
POST /query
{
    "type":"add_computed_field",
    "args":{
        "table":{
            "name":"job",
            "schema":"public"
        },
        "name":"status",
        "definition":{
            "function":{
                "name":"current_status",
                "schema":"public"
            },
            "table_argument":"job_row"
        }
    }
}
  1. Export the metadata from the console
  2. Try to import the metadata back in the console (no edits)
  3. The console displays an error:
{
    "statement": "DELETE FROM hdb_catalog.hdb_table WHERE is_system_defined <> 'true'",
    "prepared": false,
    "error": {
        "exec_status": "FatalError",
        "hint": null,
        "message": "update or delete on table \"hdb_table\" violates foreign key constraint \"hdb_computed_field_table_schema_fkey\" on table \"hdb_computed_field\"",
        "status_code": "23503",
        "description": "Key (table_schema, table_name)=(public, job) is still referenced from table \"hdb_computed_field\"."
    },
    "arguments": []
}

Thanks for looking into this

mikyoengine avatar Oct 31 '19 22:10 mikyoengine

This is fixed by #3211, which has not been merged yet (and therefore did not make it into the beta.9 release) but should be merged shortly. The fix will be in the next release.

lexi-lambda avatar Nov 01 '19 03:11 lexi-lambda

Thanks for the quick response. Will look for the feature in the next release. Much needed feature. Thanks!

mikyoengine avatar Nov 01 '19 03:11 mikyoengine