/*
 * This file is generated by jOOQ.
 */
package ervu_secret.ervu_secret.db_beans.pg_catalog.tables;


import ervu_secret.ervu_secret.db_beans.pg_catalog.PgCatalog;
import ervu_secret.ervu_secret.db_beans.pg_catalog.tables.records.PgStatsExtExprsRecord;

import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class PgStatsExtExprs extends TableImpl<PgStatsExtExprsRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>pg_catalog.pg_stats_ext_exprs</code>
     */
    public static final PgStatsExtExprs PG_STATS_EXT_EXPRS = new PgStatsExtExprs();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<PgStatsExtExprsRecord> getRecordType() {
        return PgStatsExtExprsRecord.class;
    }

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.schemaname</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> SCHEMANAME = createField(DSL.name("schemaname"), SQLDataType.VARCHAR, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.tablename</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> TABLENAME = createField(DSL.name("tablename"), SQLDataType.VARCHAR, this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stats_ext_exprs.statistics_schemaname</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> STATISTICS_SCHEMANAME = createField(DSL.name("statistics_schemaname"), SQLDataType.VARCHAR, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.statistics_name</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> STATISTICS_NAME = createField(DSL.name("statistics_name"), SQLDataType.VARCHAR, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.statistics_owner</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> STATISTICS_OWNER = createField(DSL.name("statistics_owner"), SQLDataType.VARCHAR, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.expr</code>.
     */
    public final TableField<PgStatsExtExprsRecord, String> EXPR = createField(DSL.name("expr"), SQLDataType.CLOB, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.inherited</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Boolean> INHERITED = createField(DSL.name("inherited"), SQLDataType.BOOLEAN, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.null_frac</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float> NULL_FRAC = createField(DSL.name("null_frac"), SQLDataType.REAL, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.avg_width</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Integer> AVG_WIDTH = createField(DSL.name("avg_width"), SQLDataType.INTEGER, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.n_distinct</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float> N_DISTINCT = createField(DSL.name("n_distinct"), SQLDataType.REAL, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.most_common_vals</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Object[]> MOST_COMMON_VALS = createField(DSL.name("most_common_vals"), SQLDataType.OTHER.array(), this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.most_common_freqs</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float[]> MOST_COMMON_FREQS = createField(DSL.name("most_common_freqs"), SQLDataType.REAL.array(), this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.histogram_bounds</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Object[]> HISTOGRAM_BOUNDS = createField(DSL.name("histogram_bounds"), SQLDataType.OTHER.array(), this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.correlation</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float> CORRELATION = createField(DSL.name("correlation"), SQLDataType.REAL, this, "");

    /**
     * The column <code>pg_catalog.pg_stats_ext_exprs.most_common_elems</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Object[]> MOST_COMMON_ELEMS = createField(DSL.name("most_common_elems"), SQLDataType.OTHER.array(), this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stats_ext_exprs.most_common_elem_freqs</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float[]> MOST_COMMON_ELEM_FREQS = createField(DSL.name("most_common_elem_freqs"), SQLDataType.REAL.array(), this, "");

    /**
     * The column
     * <code>pg_catalog.pg_stats_ext_exprs.elem_count_histogram</code>.
     */
    public final TableField<PgStatsExtExprsRecord, Float[]> ELEM_COUNT_HISTOGRAM = createField(DSL.name("elem_count_histogram"), SQLDataType.REAL.array(), this, "");

    private PgStatsExtExprs(Name alias, Table<PgStatsExtExprsRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private PgStatsExtExprs(Name alias, Table<PgStatsExtExprsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "pg_stats_ext_exprs" as  SELECT cn.nspname AS schemaname,
         c.relname AS tablename,
         sn.nspname AS statistics_schemaname,
         s.stxname AS statistics_name,
         pg_get_userbyid(s.stxowner) AS statistics_owner,
         stat.expr,
         sd.stxdinherit AS inherited,
         (stat.a).stanullfrac AS null_frac,
         (stat.a).stawidth AS avg_width,
         (stat.a).stadistinct AS n_distinct,
             CASE
                 WHEN ((stat.a).stakind1 = 1) THEN (stat.a).stavalues1
                 WHEN ((stat.a).stakind2 = 1) THEN (stat.a).stavalues2
                 WHEN ((stat.a).stakind3 = 1) THEN (stat.a).stavalues3
                 WHEN ((stat.a).stakind4 = 1) THEN (stat.a).stavalues4
                 WHEN ((stat.a).stakind5 = 1) THEN (stat.a).stavalues5
                 ELSE NULL::anyarray
             END AS most_common_vals,
             CASE
                 WHEN ((stat.a).stakind1 = 1) THEN (stat.a).stanumbers1
                 WHEN ((stat.a).stakind2 = 1) THEN (stat.a).stanumbers2
                 WHEN ((stat.a).stakind3 = 1) THEN (stat.a).stanumbers3
                 WHEN ((stat.a).stakind4 = 1) THEN (stat.a).stanumbers4
                 WHEN ((stat.a).stakind5 = 1) THEN (stat.a).stanumbers5
                 ELSE NULL::real[]
             END AS most_common_freqs,
             CASE
                 WHEN ((stat.a).stakind1 = 2) THEN (stat.a).stavalues1
                 WHEN ((stat.a).stakind2 = 2) THEN (stat.a).stavalues2
                 WHEN ((stat.a).stakind3 = 2) THEN (stat.a).stavalues3
                 WHEN ((stat.a).stakind4 = 2) THEN (stat.a).stavalues4
                 WHEN ((stat.a).stakind5 = 2) THEN (stat.a).stavalues5
                 ELSE NULL::anyarray
             END AS histogram_bounds,
             CASE
                 WHEN ((stat.a).stakind1 = 3) THEN (stat.a).stanumbers1[1]
                 WHEN ((stat.a).stakind2 = 3) THEN (stat.a).stanumbers2[1]
                 WHEN ((stat.a).stakind3 = 3) THEN (stat.a).stanumbers3[1]
                 WHEN ((stat.a).stakind4 = 3) THEN (stat.a).stanumbers4[1]
                 WHEN ((stat.a).stakind5 = 3) THEN (stat.a).stanumbers5[1]
                 ELSE NULL::real
             END AS correlation,
             CASE
                 WHEN ((stat.a).stakind1 = 4) THEN (stat.a).stavalues1
                 WHEN ((stat.a).stakind2 = 4) THEN (stat.a).stavalues2
                 WHEN ((stat.a).stakind3 = 4) THEN (stat.a).stavalues3
                 WHEN ((stat.a).stakind4 = 4) THEN (stat.a).stavalues4
                 WHEN ((stat.a).stakind5 = 4) THEN (stat.a).stavalues5
                 ELSE NULL::anyarray
             END AS most_common_elems,
             CASE
                 WHEN ((stat.a).stakind1 = 4) THEN (stat.a).stanumbers1
                 WHEN ((stat.a).stakind2 = 4) THEN (stat.a).stanumbers2
                 WHEN ((stat.a).stakind3 = 4) THEN (stat.a).stanumbers3
                 WHEN ((stat.a).stakind4 = 4) THEN (stat.a).stanumbers4
                 WHEN ((stat.a).stakind5 = 4) THEN (stat.a).stanumbers5
                 ELSE NULL::real[]
             END AS most_common_elem_freqs,
             CASE
                 WHEN ((stat.a).stakind1 = 5) THEN (stat.a).stanumbers1
                 WHEN ((stat.a).stakind2 = 5) THEN (stat.a).stanumbers2
                 WHEN ((stat.a).stakind3 = 5) THEN (stat.a).stanumbers3
                 WHEN ((stat.a).stakind4 = 5) THEN (stat.a).stanumbers4
                 WHEN ((stat.a).stakind5 = 5) THEN (stat.a).stanumbers5
                 ELSE NULL::real[]
             END AS elem_count_histogram
        FROM (((((pg_statistic_ext s
          JOIN pg_class c ON ((c.oid = s.stxrelid)))
          LEFT JOIN pg_statistic_ext_data sd ON ((s.oid = sd.stxoid)))
          LEFT JOIN pg_namespace cn ON ((cn.oid = c.relnamespace)))
          LEFT JOIN pg_namespace sn ON ((sn.oid = s.stxnamespace)))
          JOIN LATERAL ( SELECT unnest(pg_get_statisticsobjdef_expressions(s.oid)) AS expr,
                 unnest(sd.stxdexpr) AS a) stat ON ((stat.expr IS NOT NULL)));
        """), where);
    }

    /**
     * Create an aliased <code>pg_catalog.pg_stats_ext_exprs</code> table
     * reference
     */
    public PgStatsExtExprs(String alias) {
        this(DSL.name(alias), PG_STATS_EXT_EXPRS);
    }

    /**
     * Create an aliased <code>pg_catalog.pg_stats_ext_exprs</code> table
     * reference
     */
    public PgStatsExtExprs(Name alias) {
        this(alias, PG_STATS_EXT_EXPRS);
    }

    /**
     * Create a <code>pg_catalog.pg_stats_ext_exprs</code> table reference
     */
    public PgStatsExtExprs() {
        this(DSL.name("pg_stats_ext_exprs"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : PgCatalog.PG_CATALOG;
    }

    @Override
    public PgStatsExtExprs as(String alias) {
        return new PgStatsExtExprs(DSL.name(alias), this);
    }

    @Override
    public PgStatsExtExprs as(Name alias) {
        return new PgStatsExtExprs(alias, this);
    }

    @Override
    public PgStatsExtExprs as(Table<?> alias) {
        return new PgStatsExtExprs(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatsExtExprs rename(String name) {
        return new PgStatsExtExprs(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatsExtExprs rename(Name name) {
        return new PgStatsExtExprs(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public PgStatsExtExprs rename(Table<?> name) {
        return new PgStatsExtExprs(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs where(Condition condition) {
        return new PgStatsExtExprs(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatsExtExprs where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatsExtExprs where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatsExtExprs where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public PgStatsExtExprs where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public PgStatsExtExprs whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
