prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Spark raw String Support, comonly used with regexes
  This fails with sqlglot:
  
  ```python
  import sqlglot
  
  sql = """select regexp_replace('100-200', r'([^0-9])', '')"""
  sqlglot.parse_one(sql, read="databricks")
  ```
  
  **Official Documentation**
  https://spark.apache.org/docs/latest/sql-ref-literals.html
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sqlglot/dialects/spark.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import typing as t
  4 
  5 from sqlglot import exp
  6 from sqlglot.dialects.dialect import rename_func
  7 from sqlglot.dialects.spark2 import Spark2
  8 from sqlglot.helper import seq_get
  9 
  10 
  11 def _parse_datediff(args: t.List) -> exp.Expression:
  12     """
  13     Although Spark docs don't mention the "unit" argument, Spark3 added support for
  14     it at some point. Databricks also supports this variant (see below).
  15 
  16     For example, in spark-sql (v3.3.1):
  17     - SELECT DATEDIFF('2020-01-01', '2020-01-05') results in -4
  18     - SELECT DATEDIFF(day, '2020-01-01', '2020-01-05') results in 4
  19 
  20     See also:
  21     - https://docs.databricks.com/sql/language-manual/functions/datediff3.html
  22     - https://docs.databricks.com/sql/language-manual/functions/datediff.html
  23     """
  24     unit = None
  25     this = seq_get(args, 0)
  26     expression = seq_get(args, 1)
  27 
  28     if len(args) == 3:
  29         unit = this
  30         this = args[2]
  31 
  32     return exp.DateDiff(
  33         this=exp.TsOrDsToDate(this=this), expression=exp.TsOrDsToDate(this=expression), unit=unit
  34     )
  35 
  36 
  37 class Spark(Spark2):
  38     class Parser(Spark2.Parser):
  39         FUNCTIONS = {
  40             **Spark2.Parser.FUNCTIONS,
  41             "ANY_VALUE": lambda args: exp.AnyValue(
  42                 this=seq_get(args, 0), ignore_nulls=seq_get(args, 1)
  43             ),
  44             "DATEDIFF": _parse_datediff,
  45         }
  46 
  47         FUNCTION_PARSERS = Spark2.Parser.FUNCTION_PARSERS.copy()
  48         FUNCTION_PARSERS.pop("ANY_VALUE")
  49 
  50     class Generator(Spark2.Generator):
  51         TYPE_MAPPING = {
  52             **Spark2.Generator.TYPE_MAPPING,
  53             exp.DataType.Type.MONEY: "DECIMAL(15, 4)",
  54             exp.DataType.Type.SMALLMONEY: "DECIMAL(6, 4)",
  55             exp.DataType.Type.UNIQUEIDENTIFIER: "STRING",
  56         }
  57 
  58         TRANSFORMS = {
  59             **Spark2.Generator.TRANSFORMS,
  60             exp.StartsWith: rename_func("STARTSWITH"),
  61             exp.TimestampAdd: lambda self, e: self.func(
  62                 "DATEADD", e.args.get("unit") or "DAY", e.expression, e.this
  63             ),
  64         }
  65         TRANSFORMS.pop(exp.AnyValue)
  66         TRANSFORMS.pop(exp.DateDiff)
  67         TRANSFORMS.pop(exp.Group)
  68 
  69         def anyvalue_sql(self, expression: exp.AnyValue) -> str:
  70             return self.function_fallback_sql(expression)
  71 
  72         def datediff_sql(self, expression: exp.DateDiff) -> str:
  73             unit = self.sql(expression, "unit")
  74             end = self.sql(expression, "this")
  75             start = self.sql(expression, "expression")
  76 
  77             if unit:
  78                 return self.func("DATEDIFF", unit, start, end)
  79 
  80             return self.func("DATEDIFF", end, start)
  81
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sqlglot/dialects/spark.py b/sqlglot/dialects/spark.py
  --- a/sqlglot/dialects/spark.py
  +++ b/sqlglot/dialects/spark.py
  @@ -35,6 +35,13 @@
   
   
   class Spark(Spark2):
  +    class Tokenizer(Spark2.Tokenizer):
  +        RAW_STRINGS = [
  +            (prefix + q, q)
  +            for q in t.cast(t.List[str], Spark2.Tokenizer.QUOTES)
  +            for prefix in ("r", "R")
  +        ]
  +
       class Parser(Spark2.Parser):
           FUNCTIONS = {
               **Spark2.Parser.FUNCTIONS,
  
verification_info: {"golden_diff": "diff --git a/sqlglot/dialects/spark.py b/sqlglot/dialects/spark.py\n--- a/sqlglot/dialects/spark.py\n+++ b/sqlglot/dialects/spark.py\n@@ -35,6 +35,13 @@\n \n \n class Spark(Spark2):\n+    class Tokenizer(Spark2.Tokenizer):\n+        RAW_STRINGS = [\n+            (prefix + q, q)\n+            for q in t.cast(t.List[str], Spark2.Tokenizer.QUOTES)\n+            for prefix in (\"r\", \"R\")\n+        ]\n+\n     class Parser(Spark2.Parser):\n         FUNCTIONS = {\n             **Spark2.Parser.FUNCTIONS,\n", "issue": "Spark raw String Support, comonly used with regexes\nThis fails with sqlglot:\r\n\r\n```python\r\nimport sqlglot\r\n\r\nsql = \"\"\"select regexp_replace('100-200', r'([^0-9])', '')\"\"\"\r\nsqlglot.parse_one(sql, read=\"databricks\")\r\n```\r\n\r\n**Official Documentation**\r\nhttps://spark.apache.org/docs/latest/sql-ref-literals.html\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport typing as t\n\nfrom sqlglot import exp\nfrom sqlglot.dialects.dialect import rename_func\nfrom sqlglot.dialects.spark2 import Spark2\nfrom sqlglot.helper import seq_get\n\n\ndef _parse_datediff(args: t.List) -> exp.Expression:\n    \"\"\"\n    Although Spark docs don't mention the \"unit\" argument, Spark3 added support for\n    it at some point. Databricks also supports this variant (see below).\n\n    For example, in spark-sql (v3.3.1):\n    - SELECT DATEDIFF('2020-01-01', '2020-01-05') results in -4\n    - SELECT DATEDIFF(day, '2020-01-01', '2020-01-05') results in 4\n\n    See also:\n    - https://docs.databricks.com/sql/language-manual/functions/datediff3.html\n    - https://docs.databricks.com/sql/language-manual/functions/datediff.html\n    \"\"\"\n    unit = None\n    this = seq_get(args, 0)\n    expression = seq_get(args, 1)\n\n    if len(args) == 3:\n        unit = this\n        this = args[2]\n\n    return exp.DateDiff(\n        this=exp.TsOrDsToDate(this=this), expression=exp.TsOrDsToDate(this=expression), unit=unit\n    )\n\n\nclass Spark(Spark2):\n    class Parser(Spark2.Parser):\n        FUNCTIONS = {\n            **Spark2.Parser.FUNCTIONS,\n            \"ANY_VALUE\": lambda args: exp.AnyValue(\n                this=seq_get(args, 0), ignore_nulls=seq_get(args, 1)\n            ),\n            \"DATEDIFF\": _parse_datediff,\n        }\n\n        FUNCTION_PARSERS = Spark2.Parser.FUNCTION_PARSERS.copy()\n        FUNCTION_PARSERS.pop(\"ANY_VALUE\")\n\n    class Generator(Spark2.Generator):\n        TYPE_MAPPING = {\n            **Spark2.Generator.TYPE_MAPPING,\n            exp.DataType.Type.MONEY: \"DECIMAL(15, 4)\",\n            exp.DataType.Type.SMALLMONEY: \"DECIMAL(6, 4)\",\n            exp.DataType.Type.UNIQUEIDENTIFIER: \"STRING\",\n        }\n\n        TRANSFORMS = {\n            **Spark2.Generator.TRANSFORMS,\n            exp.StartsWith: rename_func(\"STARTSWITH\"),\n            exp.TimestampAdd: lambda self, e: self.func(\n                \"DATEADD\", e.args.get(\"unit\") or \"DAY\", e.expression, e.this\n            ),\n        }\n        TRANSFORMS.pop(exp.AnyValue)\n        TRANSFORMS.pop(exp.DateDiff)\n        TRANSFORMS.pop(exp.Group)\n\n        def anyvalue_sql(self, expression: exp.AnyValue) -> str:\n            return self.function_fallback_sql(expression)\n\n        def datediff_sql(self, expression: exp.DateDiff) -> str:\n            unit = self.sql(expression, \"unit\")\n            end = self.sql(expression, \"this\")\n            start = self.sql(expression, \"expression\")\n\n            if unit:\n                return self.func(\"DATEDIFF\", unit, start, end)\n\n            return self.func(\"DATEDIFF\", end, start)\n", "path": "sqlglot/dialects/spark.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport typing as t\n\nfrom sqlglot import exp\nfrom sqlglot.dialects.dialect import rename_func\nfrom sqlglot.dialects.spark2 import Spark2\nfrom sqlglot.helper import seq_get\n\n\ndef _parse_datediff(args: t.List) -> exp.Expression:\n    \"\"\"\n    Although Spark docs don't mention the \"unit\" argument, Spark3 added support for\n    it at some point. Databricks also supports this variant (see below).\n\n    For example, in spark-sql (v3.3.1):\n    - SELECT DATEDIFF('2020-01-01', '2020-01-05') results in -4\n    - SELECT DATEDIFF(day, '2020-01-01', '2020-01-05') results in 4\n\n    See also:\n    - https://docs.databricks.com/sql/language-manual/functions/datediff3.html\n    - https://docs.databricks.com/sql/language-manual/functions/datediff.html\n    \"\"\"\n    unit = None\n    this = seq_get(args, 0)\n    expression = seq_get(args, 1)\n\n    if len(args) == 3:\n        unit = this\n        this = args[2]\n\n    return exp.DateDiff(\n        this=exp.TsOrDsToDate(this=this), expression=exp.TsOrDsToDate(this=expression), unit=unit\n    )\n\n\nclass Spark(Spark2):\n    class Tokenizer(Spark2.Tokenizer):\n        RAW_STRINGS = [\n            (prefix + q, q)\n            for q in t.cast(t.List[str], Spark2.Tokenizer.QUOTES)\n            for prefix in (\"r\", \"R\")\n        ]\n\n    class Parser(Spark2.Parser):\n        FUNCTIONS = {\n            **Spark2.Parser.FUNCTIONS,\n            \"ANY_VALUE\": lambda args: exp.AnyValue(\n                this=seq_get(args, 0), ignore_nulls=seq_get(args, 1)\n            ),\n            \"DATEDIFF\": _parse_datediff,\n        }\n\n        FUNCTION_PARSERS = Spark2.Parser.FUNCTION_PARSERS.copy()\n        FUNCTION_PARSERS.pop(\"ANY_VALUE\")\n\n    class Generator(Spark2.Generator):\n        TYPE_MAPPING = {\n            **Spark2.Generator.TYPE_MAPPING,\n            exp.DataType.Type.MONEY: \"DECIMAL(15, 4)\",\n            exp.DataType.Type.SMALLMONEY: \"DECIMAL(6, 4)\",\n            exp.DataType.Type.UNIQUEIDENTIFIER: \"STRING\",\n        }\n\n        TRANSFORMS = {\n            **Spark2.Generator.TRANSFORMS,\n            exp.StartsWith: rename_func(\"STARTSWITH\"),\n            exp.TimestampAdd: lambda self, e: self.func(\n                \"DATEADD\", e.args.get(\"unit\") or \"DAY\", e.expression, e.this\n            ),\n        }\n        TRANSFORMS.pop(exp.AnyValue)\n        TRANSFORMS.pop(exp.DateDiff)\n        TRANSFORMS.pop(exp.Group)\n\n        def anyvalue_sql(self, expression: exp.AnyValue) -> str:\n            return self.function_fallback_sql(expression)\n\n        def datediff_sql(self, expression: exp.DateDiff) -> str:\n            unit = self.sql(expression, \"unit\")\n            end = self.sql(expression, \"this\")\n            start = self.sql(expression, \"expression\")\n\n            if unit:\n                return self.func(\"DATEDIFF\", unit, start, end)\n\n            return self.func(\"DATEDIFF\", end, start)\n", "path": "sqlglot/dialects/spark.py"}]}