Skip to content

Commit

Permalink
Adds an internal TypePrecedence object in SPI
Browse files Browse the repository at this point in the history
  • Loading branch information
johnedquinn committed Nov 18, 2024
1 parent de7d36b commit 4c9bc85
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.partiql.spi.function.builtins

import org.partiql.spi.function.Function
import org.partiql.spi.function.Parameter
import org.partiql.spi.function.builtins.TypePrecedence.TYPE_PRECEDENCE
import org.partiql.spi.internal.SqlTypeFamily
import org.partiql.spi.value.Datum
import org.partiql.types.PType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@ package org.partiql.spi.function.builtins

import org.partiql.types.PType.Kind

/**
* @return the precedence of the types for the PartiQL comparator.
* @see .TYPE_PRECEDENCE
*/
@Suppress("deprecation")
internal val TYPE_PRECEDENCE: Map<Kind, Int> = listOf(
Kind.UNKNOWN,
Kind.BOOL,
Kind.TINYINT,
Kind.SMALLINT,
Kind.INTEGER,
Kind.BIGINT,
Kind.NUMERIC,
Kind.DECIMAL,
Kind.REAL,
Kind.DOUBLE,
Kind.CHAR,
Kind.VARCHAR,
Kind.STRING,
Kind.CLOB,
Kind.BLOB,
Kind.DATE,
Kind.TIME,
Kind.TIMEZ,
Kind.TIMESTAMP,
Kind.TIMESTAMPZ,
Kind.ARRAY,
Kind.BAG,
Kind.ROW,
Kind.STRUCT,
Kind.DYNAMIC
).mapIndexed { precedence, type -> type to precedence }.toMap()
internal object TypePrecedence {

/**
* @return the precedence of the types for the PartiQL comparator.
* @see .TYPE_PRECEDENCE
*/
internal val TYPE_PRECEDENCE: Map<Kind, Int> = listOf(
Kind.UNKNOWN,
Kind.BOOL,
Kind.TINYINT,
Kind.SMALLINT,
Kind.INTEGER,
Kind.BIGINT,
Kind.NUMERIC,
Kind.DECIMAL,
Kind.REAL,
Kind.DOUBLE,
Kind.CHAR,
Kind.VARCHAR,
Kind.STRING,
Kind.CLOB,
Kind.BLOB,
Kind.DATE,
Kind.TIME,
Kind.TIMEZ,
Kind.TIMESTAMP,
Kind.TIMESTAMPZ,
Kind.ARRAY,
Kind.BAG,
Kind.ROW,
Kind.STRUCT,
Kind.DYNAMIC
).mapIndexed { precedence, type -> type to precedence }.toMap()
}

0 comments on commit 4c9bc85

Please sign in to comment.