Skip to content
master
Switch branches/tags
Code

Latest commit

* refactor: normalize underlying types of literals

This is a first cut towards resolving #3129

It adds a `_normalize` method to the `Expr` class that defaults to a
no-op, this then gets overridden in the type classes (for those types
where it is possible to have ambiuous underlying types).

For instance, there is no override for normalizing integer inputs if the
input argument is a float, since that will already be rejected by the
current type-checking.  Instead, this is normalizing values to the
closest Pythonic type available for those types that are sufficiently
ambiguous.

In this first cut, the following normalizations are made:

* `str` are cast to `uuid.UUID` if `type="uuid"`
* `int` are cast to `float` if `type=("float" | "float16" | "float32" | "float64")`
* `UUID` are cast to `str` if `type="uuid"`

The current main point of ugliness (to me) is that there are
`FloatConstant` values like `E()` that we cannot call `float()` on.
That's fine, but if I import `ops.generic` to do an `isinstance`
check it causes a circular import and everything goes boom.

There are almost certainly other types which can be normalized, this was
a first pass and we can add more.

Because `UUIDScalar` inherits first from `StringScalar` we also have to
define `_normalize` there or it grabs the stringify one.

refactor: add (redundant) type hints to dispatch functions
fix(tests): fix postgres test to expect UUID
refactor: add ids to test cases
refactor: use public API to get value of literal

* refactor: move normalize dispatcher to datatypes.py
1eb60c4

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
ci
 
 
 
 
dev
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Ibis: Python data analysis framework for Hadoop and SQL engines

Service Status
Documentation Documentation Status
Conda packages Anaconda-Server Badge
PyPI PyPI
Ibis CI Build status
Backend CI Build status
Coverage Codecov branch

Ibis is a toolbox to bridge the gap between local Python environments, remote storage, execution systems like Hadoop components (HDFS, Impala, Hive, Spark) and SQL databases. Its goal is to simplify analytical workflows and make you more productive.

Install Ibis from PyPI with:

pip install ibis-framework

or from conda-forge with

conda install ibis-framework -c conda-forge

Ibis currently provides tools for interacting with the following systems:

Learn more about using the library at http://ibis-project.org.