sqlfluff: Blocklisting SQL vendor specific data types

Following Simon Holywell’s SQL Style Guide, it would be nice to have a lint rule that you can config to check for SQL data types used in the query.

I.e. In BigQuery you can use the keyword BOOL or BOOLEAN to represent a boolean type, the lint rule could blacklist one of those and enforce only a single keyword.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (11 by maintainers)

Most upvoted comments

I’m not sure we’ve got enough clarity on what we want to do here to target this for the 0.4.0 release. I’m going to move this to the pipeline for 0.5.0

I’m late to this discussion, but I agree strongly with the premise that support for a single explicit preference is generally preferable to ambiguity, and it’s preferrable to not have both BOOL and BOOLEAN used in the same codebase (or worse, in the same file).

I actually want to propose another possible guiding principle here, which could be:

  • Prefer standard/ANSI data types and formulas when those are functionally identical to the platform-specific data type or function.

I’ve been similarly considering in my team to disallow the legacy and platform-specific ISNULL() and IFNULL() functions in preference of the ubiquitous and multi-arg COALESCE(). I’ve just reviewed code today where IFNULL() and COALESCE() are both used in the same file. My preference would be to follow shared standards and be ANSI compliant (and thereby portable to a broader range of developers), unless there’s some significant reason not to do so.

Also would prefer the standard CAST(myval as int) over myval::int which is less portable and (imho) not any more readable.