Autocompletion doesn't work in some JOIN cases.
#### System information: 
- Windows 10 Pro x64
- DBeaver 21.0.4
- No additional extensions

#### Connection specification:
- PostgreSQL 9.5
- Default PostgreSQL driver
- No tunnels or proxies

#### Describe the problem you're observing:
Column autocompletion doesn't work when table in from clause doesn't have alias
#### Steps to reproduce, if exist:
https://user-images.githubusercontent.com/22142845/116897332-cdc2a480-ac3d-11eb-8f1b-5f8d6e5ebee0.mp4




diff --git a/plugins/org.jkiss.dbeaver.model.sql/src/org/jkiss/dbeaver/model/sql/completion/SQLCompletionAnalyzer.java b/plugins/org.jkiss.dbeaver.model.sql/src/org/jkiss/dbeaver/model/sql/completion/SQLCompletionAnalyzer.java
index 33ecaf1292..15bb14763d 100644
--- a/plugins/org.jkiss.dbeaver.model.sql/src/org/jkiss/dbeaver/model/sql/completion/SQLCompletionAnalyzer.java
+++ b/plugins/org.jkiss.dbeaver.model.sql/src/org/jkiss/dbeaver/model/sql/completion/SQLCompletionAnalyzer.java
@@ -932,8 +932,16 @@ public class SQLCompletionAnalyzer implements DBRRunnableParametrized<DBRProgres
                     continue;
                 }
                 if (state == InlineState.TABLE_DOT) {
-                    if (CommonUtils.isEmpty(tableAlias)) {
+                    if (CommonUtils.isEmpty(tableAlias) && !isTableQueryToken(tok, value)) {
                         state = InlineState.MATCHED;
+                    } else if (isTableQueryToken(tok, value)) {
+                        /*
+                            Sometimes we can have table without alias, it will reset state to table_name because there is no alias to check
+                            See #12335
+                         */
+                        matchedTableName = null;
+                        state = InlineState.TABLE_NAME;
+                        continue;
                     } else {
                         state = InlineState.ALIAS_AS;
                     }
diff --git a/test/org.jkiss.dbeaver.test.platform/src/org/jkiss/dbeaver/model/sql/analyzer/SQLCompletionAnalyzerTest.java b/test/org.jkiss.dbeaver.test.platform/src/org/jkiss/dbeaver/model/sql/analyzer/SQLCompletionAnalyzerTest.java
index 7a03a6a672..26a363327b 100644
--- a/test/org.jkiss.dbeaver.test.platform/src/org/jkiss/dbeaver/model/sql/analyzer/SQLCompletionAnalyzerTest.java
+++ b/test/org.jkiss.dbeaver.test.platform/src/org/jkiss/dbeaver/model/sql/analyzer/SQLCompletionAnalyzerTest.java
@@ -147,6 +147,30 @@ public class SQLCompletionAnalyzerTest {
         }
     }
 
+    @Test
+    public void testColumnWithNonExistingAliases() throws DBException {
+        final RequestResult request = RequestBuilder.tables(s-> {
+            s.table("Table1", t -> {
+                t.attribute("Col1");
+                t.attribute("Col2");
+            });
+            s.table("Table2", t -> {
+                t.attribute("Col4");
+                t.attribute("Col5");
+            });
+        }).prepare();
+        {
+            final List<SQLCompletionProposalBase> proposals = request.request("SELECT * FROM Table1 join Table2 t on t.|", false);
+            Assert.assertEquals("Col4", proposals.get(0).getReplacementString());
+            Assert.assertEquals("Col5", proposals.get(1).getReplacementString());
+        }
+        {
+            final List<SQLCompletionProposalBase> proposals = request.request("SELECT * FROM Table1 b join Table2 on b.|", false);
+            Assert.assertEquals("Col1", proposals.get(0).getReplacementString());
+            Assert.assertEquals("Col2", proposals.get(1).getReplacementString());
+        }
+    }
+
     @Test
     public void testColumnNamesExpandCompletion() throws DBException {
         final RequestResult request = RequestBuilder
['plugins/org.jkiss.dbeaver.model.sql/src/org/jkiss/dbeaver/model/sql/completion/SQLCompletionAnalyzer.java', 'test/org.jkiss.dbeaver.test.platform/src/org/jkiss/dbeaver/model/sql/analyzer/SQLCompletionAnalyzerTest.java']