Repository: tobymao/sqlglot

Issue:
Postgres array indexes are incorrectly incremented when transpiling to Trino
Both Postgres and Trino are 1-indexed, but SQLGlot adds a 1.

```
>>> sqlglot.__version__
'16.1.3'
>>> sqlglot.transpile("select col[1]", read='postgres', write='trino')[0]
Applying array index offset (1)
'SELECT col[2]'
```

Discussion:

Patch:
diff --git a/sqlglot/dialects/postgres.py b/sqlglot/dialects/postgres.py
index f9b1cf33..8c2a4ab8 100644
--- a/sqlglot/dialects/postgres.py
+++ b/sqlglot/dialects/postgres.py
@@ -183,6 +183,7 @@ def _to_timestamp(args: t.List) -> exp.Expression:
 
 
 class Postgres(Dialect):
+    INDEX_OFFSET = 1
     NULL_ORDERING = "nulls_are_large"
     TIME_FORMAT = "'YYYY-MM-DD HH24:MI:SS'"
     TIME_MAPPING = {


Test patch:
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py
index 10262471..48a89c3a 100644
--- a/tests/dialects/test_postgres.py
+++ b/tests/dialects/test_postgres.py
@@ -107,6 +107,16 @@ class TestPostgres(Validator):
             },
         )
 
+    def test_array_offset(self):
+        self.validate_all(
+            "SELECT col[1]",
+            write={
+                "hive": "SELECT col[0]",
+                "postgres": "SELECT col[1]",
+                "presto": "SELECT col[1]",
+            },
+        )
+
     def test_postgres(self):
         self.validate_identity("CAST(x AS INT4RANGE)")
         self.validate_identity("CAST(x AS INT4MULTIRANGE)")