Skip to content

Commit

Permalink
Fix column name bug unpivoted data
Browse files Browse the repository at this point in the history
  • Loading branch information
rcboufleur committed Dec 8, 2024
1 parent 28a900c commit 59d2e2a
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -135,12 +137,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2135,12 +2135,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -4245,12 +4247,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2135,12 +2135,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -4245,12 +4247,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down
4 changes: 4 additions & 0 deletions python/lsst/consdb/efd_transform/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ def build_argparser() -> argparse.ArgumentParser:
f.write(" datatype: char\n")
f.write(" length: 255\n")
f.write(" nullable: False\n")
f.write(" value: default_property\n")
f.write(" description: Property name for the unpivoted data\n")
f.write(" - name: field\n")
f.write(' "@id": "#exposure_efd_unpivoted.field"\n')
f.write(" datatype: char\n")
f.write(" length: 255\n")
f.write(" nullable: False\n")
f.write(" value: default_field\n")
f.write(" description: Field name for the unpivoted data\n")
f.write(" - name: value\n")
f.write(' "@id": "#exposure_efd_unpivoted.value"\n')
Expand Down Expand Up @@ -214,12 +216,14 @@ def build_argparser() -> argparse.ArgumentParser:
f.write(" datatype: char\n")
f.write(" length: 255\n")
f.write(" nullable: False\n")
f.write(" value: default_property\n")
f.write(" description: Property name for the unpivoted data\n")
f.write(" - name: field\n")
f.write(' "@id": "#visit1_efd_unpivoted.field"\n')
f.write(" datatype: char\n")
f.write(" length: 255\n")
f.write(" nullable: False\n")
f.write(" value: default_field\n")
f.write(" description: Field name for the unpivoted data\n")
f.write(" - name: value\n")
f.write(' "@id": "#visit1_efd_unpivoted.value"\n')
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/consdb/efd_transform/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ def process_interval(
result_exp_unpivoted.append(
{
"exposure_id": exposure["id"],
"topic": column["name"],
"column": col,
"property": column["name"],
"field": col,
"value": column_value,
}
)
Expand Down Expand Up @@ -295,8 +295,8 @@ def process_interval(
result_vis_unpivoted.append(
{
"visit_id": visit["id"],
"topic": topic,
"column": col,
"property": topic,
"field": col,
"value": column_value,
}
)
Expand Down
8 changes: 4 additions & 4 deletions tests/efd_transform/LATISS-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ COMMENT ON CONSTRAINT un_exposure_id_instrument ON cdb_latiss.exposure_efd IS 'E

CREATE TABLE cdb_latiss.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand Down Expand Up @@ -50,8 +50,8 @@ COMMENT ON CONSTRAINT un_visit_id_instrument ON cdb_latiss.visit1_efd IS 'Ensure

CREATE TABLE cdb_latiss.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
8 changes: 4 additions & 4 deletions tests/efd_transform/LATISS-sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ CREATE TABLE main.exposure_efd (

CREATE TABLE main.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand All @@ -33,8 +33,8 @@ CREATE TABLE main.visit1_efd (

CREATE TABLE main.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
Binary file modified tests/efd_transform/LATISS.db
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/efd_transform/LSSTComCam-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ COMMENT ON CONSTRAINT un_exposure_id_instrument ON cdb_lsstcomcam.exposure_efd I

CREATE TABLE cdb_lsstcomcam.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand Down Expand Up @@ -1694,8 +1694,8 @@ COMMENT ON CONSTRAINT un_visit_id_instrument ON cdb_lsstcomcam.visit1_efd IS 'En

CREATE TABLE cdb_lsstcomcam.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
8 changes: 4 additions & 4 deletions tests/efd_transform/LSSTComCam-sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ CREATE TABLE main.exposure_efd (

CREATE TABLE main.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand Down Expand Up @@ -855,8 +855,8 @@ CREATE TABLE main.visit1_efd (

CREATE TABLE main.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
Binary file modified tests/efd_transform/LSSTComCam.db
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/efd_transform/LSSTComCamSim-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ COMMENT ON CONSTRAINT un_exposure_id_instrument ON cdb_lsstcomcamsim.exposure_ef

CREATE TABLE cdb_lsstcomcamsim.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand Down Expand Up @@ -1694,8 +1694,8 @@ COMMENT ON CONSTRAINT un_visit_id_instrument ON cdb_lsstcomcamsim.visit1_efd IS

CREATE TABLE cdb_lsstcomcamsim.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE PRECISION,
created_at TIMESTAMP WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
8 changes: 4 additions & 4 deletions tests/efd_transform/LSSTComCamSim-sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ CREATE TABLE main.exposure_efd (

CREATE TABLE main.exposure_efd_unpivoted (
exposure_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (exposure_id, property, field),
Expand Down Expand Up @@ -855,8 +855,8 @@ CREATE TABLE main.visit1_efd (

CREATE TABLE main.visit1_efd_unpivoted (
visit_id INTEGER NOT NULL,
property CHAR(255) NOT NULL,
field CHAR(255) NOT NULL,
property CHAR(255) DEFAULT 'default_property' NOT NULL,
field CHAR(255) DEFAULT 'default_field' NOT NULL,
value DOUBLE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (visit_id, property, field),
Expand Down
Binary file modified tests/efd_transform/LSSTComCamSim.db
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/efd_transform/cdb_transformed_efd_LATISS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -135,12 +137,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down
4 changes: 4 additions & 0 deletions tests/efd_transform/cdb_transformed_efd_LSSTComCam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,12 +2135,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -4245,12 +4247,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down
4 changes: 4 additions & 0 deletions tests/efd_transform/cdb_transformed_efd_LSSTComCamSim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,12 +2135,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#exposure_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#exposure_efd_unpivoted.value"
Expand Down Expand Up @@ -4245,12 +4247,14 @@ tables:
datatype: char
length: 255
nullable: False
value: default_property
description: Property name for the unpivoted data
- name: field
"@id": "#visit1_efd_unpivoted.field"
datatype: char
length: 255
nullable: False
value: default_field
description: Field name for the unpivoted data
- name: value
"@id": "#visit1_efd_unpivoted.value"
Expand Down

0 comments on commit 59d2e2a

Please sign in to comment.