-- staging_tables.sql
-- Create tables in the staging schema for raw data from external sources

CREATE TABLE IF NOT EXISTS staging.equis(
    LATITUDE DOUBLE,
    LONGITUDE DOUBLE,
    WID_LIST VARCHAR,
    SAMPLE_METHOD VARCHAR,
    SAMPLE_REMARK VARCHAR,
    FACILITY_ID BIGINT,
    FACILITY_NAME VARCHAR,
    FACILITY_TYPE VARCHAR,
    SYS_LOC_CODE VARCHAR,
    LOC_NAME VARCHAR,
    LOC_TYPE VARCHAR,
    LOC_TYPE_2 VARCHAR,
    TASK_CODE VARCHAR,
    SAMPLE_ID BIGINT,
    SYS_SAMPLE_CODE VARCHAR,
    TEST_ID BIGINT,
    ANALYTE_TYPE VARCHAR,
    ANALYTE_TYPE_DESC VARCHAR,
    ANALYTIC_METHOD VARCHAR,
    PREFERRED_NAME VARCHAR,
    PARAMETER VARCHAR,
    CAS_RN VARCHAR,
    CHEMICAL_NAME VARCHAR,
    GTLT VARCHAR,
    RESULT_TEXT VARCHAR,
    RESULT_NUMERIC DOUBLE,
    RESULT_UNIT VARCHAR,
    STAT_TYPE INTEGER,
    VALUE_TYPE VARCHAR,
    DETECT_FLAG VARCHAR,
    DETECT_DESC VARCHAR,
    RESULT_REMARK VARCHAR,
    RESULT_TYPE_CODE VARCHAR,
    METHOD_DETECTION_LIMIT VARCHAR,
    REPORTING_DETECTION_LIMIT VARCHAR,
    QUANTITATION_LIMIT INTEGER,
    LAB_QUALIFIERS VARCHAR,
    INTERPRETED_QUALIFIERS VARCHAR,
    REPORTABLE_RESULT VARCHAR,
    APPROVAL_CODE VARCHAR,
    SENSITIVE_NOTPUBLIC VARCHAR,
    TEST_TYPE VARCHAR,
    DILUTION_FACTOR DOUBLE,
    FRACTION VARCHAR,
    BASIS VARCHAR,
    TEMP_BASIS VARCHAR,
    TEST_REMARK VARCHAR,
    ANALYSIS_DATE_TIME TIMESTAMP_NS,
    ANALYSIS_DATE VARCHAR,
    ANALYSIS_TIME VARCHAR,
    ANALYSIS_DATE_TIMEZONE VARCHAR,
    COMPANY_NAME VARCHAR,
    LAB_NAME_CODE VARCHAR,
    LAB_SAMPLE_ID VARCHAR,
    SAMPLE_TYPE_GROUP VARCHAR,
    SAMPLE_TYPE_CODE VARCHAR,
    SAMPLE_TYPE_DESC VARCHAR,
    MEDIUM_CODE VARCHAR,
    MATRIX_CODE VARCHAR,
    START_DEPTH DOUBLE,
    DEPTH_UNIT VARCHAR,
    SAMPLE_DATE_TIME TIMESTAMP_NS,
    SAMPLE_DATE VARCHAR,
    SAMPLE_TIME VARCHAR,
    SAMPLE_DATE_TIMEZONE VARCHAR,
    EBATCH DOUBLE
);

CREATE TABLE IF NOT EXISTS staging.wiski(
    "Timestamp" VARCHAR,
    "Value" DOUBLE,
    "Quality Code" BIGINT,
    "Quality Code Name" VARCHAR,
    ts_unitsymbol VARCHAR,
    ts_name VARCHAR,
    ts_id VARCHAR,
    station_no VARCHAR,
    station_name VARCHAR,
    station_latitude VARCHAR,
    station_longitude VARCHAR,
    parametertype_id VARCHAR,
    parametertype_name VARCHAR,
    stationparameter_no VARCHAR,
    stationparameter_name VARCHAR,
    wplmn_flag BIGINT
);
