Я считаю, rlike
должен сделать трюк:
spark.sql("""SELECT '123456789' rlike '\\\d{9}' as val""").show()
spark.sql("""SELECT 'ab123456789' rlike '\\\d{9}' as val""").show()
spark.sql("""SELECT '123456789abcd' rlike '\\\d{9}' as val""").show()
Весь результат в:
+----+
| val|
+----+
|true|
+----+
И:
spark.sql("""SELECT '12345678abcd' rlike '\\\d{9}' as val""").show()
Результаты:
+-----+
| val|
+-----+
|false|
+-----+