<commit_before>DROP FUNCTION IF EXISTS photo.get_photo_metadata(BOOLEAN, INTEGER);

CREATE OR REPLACE FUNCTION photo.get_photo_metadata
(
    _roles TEXT[],
    _id INTEGER DEFAULT NULL
)
RETURNS TABLE
(
    bits_per_sample SMALLINT,
    compression VARCHAR(80),
    contrast VARCHAR(10),
    create_date TIMESTAMP,
    digital_zoom_ratio REAL,
    exposure_compensation VARCHAR(10),
    exposure_mode VARCHAR(50),
    exposure_program VARCHAR(50),
    exposure_time VARCHAR(10),
    f_number NUMERIC(3, 1),
    flash VARCHAR(60),
    focal_length REAL,
    focal_length_in_35_mm_format REAL,
    gain_control VARCHAR(20),
    gps_altitude REAL,
    gps_alititude_ref VARCHAR(20),
    gps_date_stamp TIMESTAMP,
    gps_direction REAL,
    gps_direction_ref VARCHAR(20),
    gps_latitude REAL,
    gps_latitude_ref VARCHAR(10),
    gps_longitude REAL,
    gps_longitude_ref VARCHAR(10),
    gps_measure_mode VARCHAR(30),
    gps_satellites VARCHAR(150),
    gps_status VARCHAR(20),
    gps_version_id VARCHAR(16),
    iso INTEGER,
    light_source VARCHAR(30),
    make VARCHAR(50),
    metering_mode VARCHAR(50),
    model VARCHAR(50),
    orientation VARCHAR(50),
    saturation VARCHAR(50),
    scene_capture_type VARCHAR(50),
    scene_type VARCHAR(50),
    sensing_method VARCHAR(50),
    sharpness VARCHAR(50),
    auto_focus_area_mode VARCHAR(10),
    auto_focus_point VARCHAR(30),
    active_d_lighting VARCHAR(20),
    colorspace VARCHAR(15),
    exposure_difference REAL,
    flash_color_filter VARCHAR(10),
    flash_compensation VARCHAR(10),
    flash_control_mode SMALLINT,
    flash_exposure_compensation VARCHAR(10),
    flash_focal_length SMALLINT,
    flash_mode VARCHAR(30),
    flash_setting VARCHAR(50),
    flash_type VARCHAR(60),
    focus_distance REAL,
    focus_mode VARCHAR(50),
    focus_position SMALLINT,
    high_iso_noise_reduction VARCHAR(20),
    hue_adjustment VARCHAR(50),
    noise_reduction VARCHAR(50),
    picture_control_name VARCHAR(50),
    primary_af_point VARCHAR(20),
    vr_mode VARCHAR(20),
    vibration_reduction VARCHAR(10),
    vignette_control VARCHAR(10),
    white_balance VARCHAR(50),
    aperture NUMERIC(3, 1),
    auto_focus VARCHAR(10),
    depth_of_field VARCHAR(50),
    field_of_view VARCHAR(50),
    hyperfocal_distance REAL,
    lens_id VARCHAR(100),
    light_value REAL,
    scale_factor_35_efl REAL,
    shutter_speed VARCHAR(50)
)
LANGUAGE SQL
AS $$

    SELECT p.bits_per_sample,
           cm.name AS compression,
           cn.name AS contrast,
           create_date,
           digital_zoom_ratio,
           exposure_compensation,
           em.name AS exposure_mode,
           ep.name AS exposure_program,
           exposure_time,
           f_number,
           f.name AS flash,
           focal_length,
           focal_length_in_35_mm_format,
           gc.name AS gain_control,
           gps_altitude,
           gpsar.name AS gps_alititude_ref,
           gps_date_time_stamp AS gps_date_stamp,
           gps_direction,
           gpsdr.name AS gps_direction_ref,
           gps_latitude,
           gpslatr.name AS gps_latitude_ref,
           gps_longitude,
           gpslngr.name AS gps_longitude_ref,<commit_msg>add a distinct for good measure<commit_after>DROP FUNCTION IF EXISTS photo.get_photo_metadata(BOOLEAN, INTEGER);

CREATE OR REPLACE FUNCTION photo.get_photo_metadata
(
    _roles TEXT[],
    _id INTEGER DEFAULT NULL
)
RETURNS TABLE
(
    bits_per_sample SMALLINT,
    compression VARCHAR(80),
    contrast VARCHAR(10),
    create_date TIMESTAMP,
    digital_zoom_ratio REAL,
    exposure_compensation VARCHAR(10),
    exposure_mode VARCHAR(50),
    exposure_program VARCHAR(50),
    exposure_time VARCHAR(10),
    f_number NUMERIC(3, 1),
    flash VARCHAR(60),
    focal_length REAL,
    focal_length_in_35_mm_format REAL,
    gain_control VARCHAR(20),
    gps_altitude REAL,
    gps_alititude_ref VARCHAR(20),
    gps_date_stamp TIMESTAMP,
    gps_direction REAL,
    gps_direction_ref VARCHAR(20),
    gps_latitude REAL,
    gps_latitude_ref VARCHAR(10),
    gps_longitude REAL,
    gps_longitude_ref VARCHAR(10),
    gps_measure_mode VARCHAR(30),
    gps_satellites VARCHAR(150),
    gps_status VARCHAR(20),
    gps_version_id VARCHAR(16),
    iso INTEGER,
    light_source VARCHAR(30),
    make VARCHAR(50),
    metering_mode VARCHAR(50),
    model VARCHAR(50),
    orientation VARCHAR(50),
    saturation VARCHAR(50),
    scene_capture_type VARCHAR(50),
    scene_type VARCHAR(50),
    sensing_method VARCHAR(50),
    sharpness VARCHAR(50),
    auto_focus_area_mode VARCHAR(10),
    auto_focus_point VARCHAR(30),
    active_d_lighting VARCHAR(20),
    colorspace VARCHAR(15),
    exposure_difference REAL,
    flash_color_filter VARCHAR(10),
    flash_compensation VARCHAR(10),
    flash_control_mode SMALLINT,
    flash_exposure_compensation VARCHAR(10),
    flash_focal_length SMALLINT,
    flash_mode VARCHAR(30),
    flash_setting VARCHAR(50),
    flash_type VARCHAR(60),
    focus_distance REAL,
    focus_mode VARCHAR(50),
    focus_position SMALLINT,
    high_iso_noise_reduction VARCHAR(20),
    hue_adjustment VARCHAR(50),
    noise_reduction VARCHAR(50),
    picture_control_name VARCHAR(50),
    primary_af_point VARCHAR(20),
    vr_mode VARCHAR(20),
    vibration_reduction VARCHAR(10),
    vignette_control VARCHAR(10),
    white_balance VARCHAR(50),
    aperture NUMERIC(3, 1),
    auto_focus VARCHAR(10),
    depth_of_field VARCHAR(50),
    field_of_view VARCHAR(50),
    hyperfocal_distance REAL,
    lens_id VARCHAR(100),
    light_value REAL,
    scale_factor_35_efl REAL,
    shutter_speed VARCHAR(50)
)
LANGUAGE SQL
AS $$

    SELECT DISTINCT
           p.bits_per_sample,
           cm.name AS compression,
           cn.name AS contrast,
           create_date,
           digital_zoom_ratio,
           exposure_compensation,
           em.name AS exposure_mode,
           ep.name AS exposure_program,
           exposure_time,
           f_number,
           f.name AS flash,
           focal_length,
           focal_length_in_35_mm_format,
           gc.name AS gain_control,
           gps_altitude,
           gpsar.name AS gps_alititude_ref,
           gps_date_time_stamp AS gps_date_stamp,
           gps_direction,
           gpsdr.name AS gps_direction_ref,
           gps_latitude,
           gpslatr.name AS gps_latitude_ref,
           gps_longitude,
           gpslngr.name AS gps_longitude_ref,
{'fraction_non_alphanumeric': 0.0717614165890028, 'fraction_numerical': 0.035414725069897485, 'mean_word_length': 3.1065051020408165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7247326', 'n_tokens_mistral': 2368, 'n_tokens_neox': 2070, 'n_words': 433}