Repository: tobymao/sqlglot

Issue:
[TSQL] DATENAME is replaced incorrectly
# Issue Description

sqlglot==13.3.0

**Code**
```python
query = "Select DATENAME(dw, some_date) FROM my_table"
query = parse_one(query, dialect='tsql')
print(query)
```

**Output**
```sql
Select FORMAT(some_date, '%A') AS day FROM my_table
```

**Expected Output**
```
Select FORMAT(some_date, 'dddd') AS day FROM my_table
```

## Analysis

> format
nvarchar format pattern.
The format argument must contain a valid .NET Framework format string, either as a standard format string (for example, "C" or "D"), or as a pattern of custom characters for dates and numeric values (for example, "MMMM DD, yyyy (dddd)"). Composite formatting is not supported. For a full explanation of these formatting patterns, consult the .NET Framework documentation on string formatting in general, custom date and time formats, and custom number formats. A good starting point is the topic, "[Formatting Types](https://learn.microsoft.com/en-us/dotnet/standard/base-types/formatting-types)."

The correct format should be `dddd`. See [here](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings#ddddSpecifier) for more info.


## Additional Question
Could you please provide the rationale behind replacing DATENAME with FORMAT? Also, in general why are some functions replaced but not others?


Discussion:

Patch:
diff --git a/sqlglot/dialects/tsql.py b/sqlglot/dialects/tsql.py
index 13a5a6c5..a2812972 100644
--- a/sqlglot/dialects/tsql.py
+++ b/sqlglot/dialects/tsql.py
@@ -243,6 +243,7 @@ class TSQL(Dialect):
         "MMM": "%b",
         "MM": "%m",
         "M": "%-m",
+        "dddd": "%A",
         "dd": "%d",
         "d": "%-d",
         "HH": "%H",
diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py
index 35c9a8eb..08c04cf9 100644
--- a/sqlglot/expressions.py
+++ b/sqlglot/expressions.py
@@ -5049,7 +5049,7 @@ class FromBase(Func):
 
 
 class Struct(Func):
-    arg_types = {"expressions": True}
+    arg_types = {"expressions": False}
     is_var_len_args = True
 
 


Test patch:
diff --git a/tests/dialects/test_snowflake.py b/tests/dialects/test_snowflake.py
index 9164e525..2cad1d24 100644
--- a/tests/dialects/test_snowflake.py
+++ b/tests/dialects/test_snowflake.py
@@ -13,6 +13,7 @@ class TestSnowflake(Validator):
         expr.selects[0].assert_is(exp.AggFunc)
         self.assertEqual(expr.sql(dialect="snowflake"), "SELECT APPROX_TOP_K(C4, 3, 5) FROM t")
 
+        self.validate_identity("SELECT OBJECT_CONSTRUCT()")
         self.validate_identity("SELECT DAYOFMONTH(CURRENT_TIMESTAMP())")
         self.validate_identity("SELECT DAYOFYEAR(CURRENT_TIMESTAMP())")
         self.validate_identity("LISTAGG(data['some_field'], ',')")
diff --git a/tests/dialects/test_tsql.py b/tests/dialects/test_tsql.py
index 479f87b9..0ac94f2a 100644
--- a/tests/dialects/test_tsql.py
+++ b/tests/dialects/test_tsql.py
@@ -855,12 +855,18 @@ WHERE
 
     def test_datename(self):
         self.validate_all(
-            "SELECT DATENAME(mm,'1970-01-01')",
-            write={"spark": "SELECT DATE_FORMAT(CAST('1970-01-01' AS TIMESTAMP), 'MMMM')"},
+            "SELECT DATENAME(mm, '1970-01-01')",
+            write={
+                "spark": "SELECT DATE_FORMAT(CAST('1970-01-01' AS TIMESTAMP), 'MMMM')",
+                "tsql": "SELECT FORMAT(CAST('1970-01-01' AS DATETIME2), 'MMMM')",
+            },
         )
         self.validate_all(
-            "SELECT DATENAME(dw,'1970-01-01')",
-            write={"spark": "SELECT DATE_FORMAT(CAST('1970-01-01' AS TIMESTAMP), 'EEEE')"},
+            "SELECT DATENAME(dw, '1970-01-01')",
+            write={
+                "spark": "SELECT DATE_FORMAT(CAST('1970-01-01' AS TIMESTAMP), 'EEEE')",
+                "tsql": "SELECT FORMAT(CAST('1970-01-01' AS DATETIME2), 'dddd')",
+            },
         )
 
     def test_datepart(self):