'Snowflake - How do I handle a bad Virtual Column after it is INSERTed?

I am surprise that I can insert a Row that results in a Virtual Column going bad. How then do I detect the bad Virtual Columns and handle it (especially in code)?

CREATE TABLE TEST
(
  REC_DATE          VARCHAR2(500),
  REC_TIME          VARCHAR2(500),
  REC_DATETIME      DATETIME AS TO_TIMESTAMP( REC_DATE || ' ' || REC_TIME, 'DD/MM/YYYY HH24:MI:SS'  )
);

INSERT INTO TEST ( REC_DATE, REC_TIME ) VALUES ( '02/02/2022', '02:22:22' );
INSERT INTO TEST ( REC_DATE, REC_TIME ) VALUES ( '03/03/2023', '03:33:33' );

And then insert a bad row that results in the bad Virtual Column:

INSERT INTO TEST ( REC_DATE, REC_TIME ) VALUES ( '02/02/2022', '99:22:22' );

SELECT * FROM TEST;

and you should get this error:

"SQL compilation error: error line 1 at position 7 invalid identifier 'TEST'"

I wonder how you would detect and weed out the bad rows, especially if there is a lot of data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source