Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column.is_integer() method #1969

Closed
clrcrl opened this issue Dec 3, 2019 · 5 comments
Closed

Column.is_integer() method #1969

clrcrl opened this issue Dec 3, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@clrcrl
Copy link
Contributor

clrcrl commented Dec 3, 2019

The Column class has an instance method, is_numeric() that returns true if the column is a fixed-precision Numeric type (eg. numeric), else False (including integer and float types).

There are instances where I want to determine:

  • Is this column generally numeric? I.e. one of: decimal, float, integer
  • Is this column an integer? i.e. one of bigint, smallint, integer (e.g. on Redshift).

The second one is easy: let's add an is_integer() method.
But I don't know how to name the first method, since is_numeric() is already reserved for numeric (i.e. decimal) columns. Can we rename is_numeric to is_decimal, or will that mess up too many things?

@clrcrl clrcrl added enhancement New feature or request triage labels Dec 3, 2019
@drewbanin drewbanin removed the triage label Dec 3, 2019
@drewbanin
Copy link
Contributor

I don't think renaming is_numeric() is a good idea. Can we instead name this new method is_number()? numeric is a well-defined type on pg/redshift/snowflake/bigquery/etc. We'll probably also want to add a method for is_float().

The is_number() implementation could just check if a column is_integer() or is_numeric() or is_float().

@drewbanin drewbanin added this to the 0.15.2: Barbara Gittings milestone Dec 3, 2019
@drewbanin
Copy link
Contributor

@clrcrl are you interested in contributing a PR for this issue? It might be a little tricky with differing semantics between each of the databases that dbt supports, but the code will be pretty straightforward to implement after some fact-finding work :)

@clrcrl
Copy link
Contributor Author

clrcrl commented Dec 5, 2019

Yeah I could do that for sure!

@clrcrl clrcrl self-assigned this Dec 5, 2019
@clrcrl clrcrl removed their assignment Jan 13, 2020
@clrcrl
Copy link
Contributor Author

clrcrl commented Jan 13, 2020

Happy for @beckjake to take this one!

@beckjake
Copy link
Contributor

Fixed in #2046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants