code: def test_sql_substr() -> None:
      df = pl.DataFrame({"scol": ["abcdefg", "abcde", "abc", None]})
      with pl.SQLContext(df=df) as ctx:
          res = ctx.execute(
              """
              SELECT
                -- note: sql is 1-indexed
                SUBSTR(scol,1) AS s1,
                SUBSTR(scol,2) AS s2,
                SUBSTR(scol,3) AS s3,
                SUBSTR(scol,1,5) AS s1_5,
                SUBSTR(scol,2,2) AS s2_2,
                SUBSTR(scol,3,1) AS s3_1,
              FROM df
              """
          ).collect()
  
      assert res.to_dict(as_series=False) == {
          "s1": ["abcdefg", "abcde", "abc", None],
          "s2": ["bcdefg", "bcde", "bc", None],
          "s3": ["cdefg", "cde", "c", None],
          "s1_5": ["abcde", "abcde", "abc", None],
          "s2_2": ["bc", "bc", "bc", None],
          "s3_1": ["c", "c", "c", None],
      }
  
      # negative indexes are expected to be invalid
      with pytest.raises(
          InvalidOperationError,
          match="Invalid 'start' for Substring: -1",
      ), pl.SQLContext(df=df) as ctx:
          ctx.execute("SELECT SUBSTR(scol,-1) FROM df")
  
imports: from __future__ import annotations
  import datetime
  import math
  from pathlib import Path
  import pytest
  import polars
  import polars.selectors
  from polars.exceptions import ComputeError, InvalidOperationError
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 28 for calling a global function with example usage: test_sql_substr() without return types