SQL Server's isNumeric() equivalent in amazon redshift

后端 未结 8 1893
庸人自扰
庸人自扰 2021-01-04 02:17
  • I\'m using amazon redshift as my data warehouse
  • I have a field (field1)of type string. Some of the strings start with four numbers and others with letters:
8条回答
  •  囚心锁ツ
    2021-01-04 02:55

    Per Amazon, the posix style ~regex style expressions are slow... https://docs.aws.amazon.com/redshift/latest/dg/pattern-matching-conditions.html

    Using their own REGEXP_* functions seems to be faster. https://docs.aws.amazon.com/redshift/latest/dg/String_functions_header.html

    For checking just a true/false for integers I've been using the following with success. REGEXP_COUNT(my_field_to_check, '^[0-9]+$') > 0

    this returns 1 if only numeric, 0 if anything else

提交回复
热议问题