Repository: kayak/pypika (Python)

Issue:
Snowflake ALIAS_QUOTE_CHAR seem to be wrong
Hi all,

we at Joyn have recently started using pypika and we love it. There is only one issue, the SnowFlakeQueryBuilder alias quote char seem to be wrong as it leads to queries that snowflake does not accept. As an example
```python
from pypika.dialects import SnowflakeQuery
from pypika import Table
t = Table("tbl")
q = SnowflakeQuery().from_(t).select(t.name.as_("aliased_name"))
print(q)
### outputs
SELECT name "aliased_name" FROM tbl
```
Expected output would be
```python
SELECT name aliased_name FROM tbl
```
To fix that, we have to set
SnowFlakeQueryBuilder.ALIAS_QUOTE_CHAR = None in every file and project. Not sure if this is something that could be fixed directly in the lib


Discussion:
There was a similar issue with Postgresql recently, fixed in https://github.com/kayak/pypika/pull/411. 

If you have time to fix this feel free to raise a PR against the repo!
@Shawe82 I am going to roll back the fix for this, as there are use cases where double quotes around alias' are required, e.g. if a special character such as a $ is used in the alias. 

If you provide more info as to what the snowflake error is, we can look at supporting all the valid use cases.

@mikeengland Thanks for letting me know. I just got the info from a colleague so I had to recheck. The issue is I think rather in joins. So for example 
``` python
from pypika import Table
from pypika.dialects import SnowflakeQuery
t1 = Table("data1")
t2 = Table("data2")
q1 = SnowflakeQuery.from_(t1).select(t1.b).as_("q1")
q2 = SnowflakeQuery.from_(t2).select(t2.b).as_("q2")
q3=SnowflakeQuery.from_(q1).join(q2).on(q1.b==q2.b).select("*")
```
would result in 
`SELECT * FROM (SELECT b FROM data1) "q1" JOIN (SELECT b FROM data2) "q2" ON q1.b=q2.b ` which doesn't work. What would work is either 
`SELECT * FROM (SELECT b FROM data1) q1 JOIN (SELECT b FROM data2) q2 ON q1.b=q2.b
` so no quote chars around query aliases, or
`SELECT * FROM (SELECT b FROM data1) "q1" JOIN (SELECT b FROM data2) "q2" ON "q1".b="q2".b` so using the quote chars when referring to the aliases.



Patch:
diff --git a/pypika/dialects.py b/pypika/dialects.py
index 65ef8708..df3fb3f9 100644
--- a/pypika/dialects.py
+++ b/pypika/dialects.py
@@ -26,7 +26,6 @@
 
 class SnowFlakeQueryBuilder(QueryBuilder):
     QUOTE_CHAR = None
-    ALIAS_QUOTE_CHAR = '"'
 
     def __init__(self, **kwargs: Any) -> None:
         super().__init__(


Test patch:
diff --git a/pypika/tests/dialects/test_snowflake.py b/pypika/tests/dialects/test_snowflake.py
index b42c9bb8..8ac55a84 100644
--- a/pypika/tests/dialects/test_snowflake.py
+++ b/pypika/tests/dialects/test_snowflake.py
@@ -13,7 +13,7 @@ class QuoteTests(unittest.TestCase):
     def test_use_double_quotes_on_alias_but_not_on_terms(self):
         q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar"))
 
-        self.assertEqual('SELECT a "bar" ' "FROM abc", q.get_sql(with_namespace=True))
+        self.assertEqual('SELECT a bar FROM abc', q.get_sql(with_namespace=True))
 
     def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self):
         foo = self.table_abc.as_("foo")
@@ -28,8 +28,8 @@ def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self):
 
         self.assertEqual(
             "SELECT foo.a,bar.b "
-            'FROM abc "foo" '
-            'JOIN efg "bar" '
+            'FROM abc foo '
+            'JOIN efg bar '
             "ON foo.fk=bar.id",
             q.get_sql(with_namespace=True),
         )
@@ -45,9 +45,9 @@ def test_use_double_quotes_on_alias_but_not_on_terms(self):
         )
 
         self.assertEqual(
-            'SELECT index "idx",SUM(value) "val" '
+            'SELECT index idx,SUM(value) val '
             "FROM abc "
-            'GROUP BY "idx" '
-            'ORDER BY "idx"',
+            'GROUP BY idx '
+            'ORDER BY idx',
             q.get_sql(with_namespace=True),
         )