# Dremio generate wrong sql

**URL:** <https://community.dremio.com/t/dremio-generate-wrong-sql/6007>\
**Category:** Uncategorized\
**Created:** [July 28, 2020, 7:04am UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007 "2020-07-28T07:04:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacopan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dacopan/32/4289_2.png) [@dacopan](https://community.dremio.com/u/dacopan)\
**Post date:** [July 28, 2020, 7:04am UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/1 "2020-07-28T07:04:34Z")

</div>

Hi, Dremio in `4.0.5-201911202046080257-19b10938` generate a query without alias but  
after upgrade to latest dremio version the query generate is:

```sql
SELECT "AH_CUENTA"."OFICIAL_CUENTA", "AH_CUENTA"."AGENCIA", "AH_CUENTA"."NUM_CTA_AHORRO", "AH_CUENTA"."ID_CLIENTE", "AH_CUENTA"."STATUS_CUENTA", "AH_CUENTA"."TIPO_CUENTA", "AH_CUENTA"."SALDO_CUENTA", "AH_CUENTA"."SALDO_DISPONIBLE", "AH_CUENTA"."CHEQUES", "AH_CUENTA"."BLOQUEOS", "AH_CUENTA"."FECHA", "AH_CUENTA"."PLAZO"
FROM "REPORTES"."AH_CUENTA" FETCH FIRST 2000 ROWS ONLY

```

Note that dremio adds `"AH_CUENTA"` in each table column but this causes fail in origin datasource because `"AH_CUENTA"` is not an alias.

[6ca32154-34d8-4fb5-9082-2d10fdfba48e.zip](https://community.dremio.com/uploads/short-url/hLslqnVJdWR2v6f9kjGrc1MoHis.zip) (13,1 KB)

---

<div class="post-metadata">

**Author:** ![dacopan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dacopan/32/4289_2.png) [@dacopan](https://community.dremio.com/u/dacopan)\
**Post date:** [July 28, 2020, 6:27pm UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/2 "2020-07-28T18:27:14Z")

</div>

@balaji.ramaswamy @ben please can you help explain?  
apprently after upgrade dremio generate `"AH_CUENTA"."OFICIAL_CUENTA"` as column name but this is incorrect de column name is only `"OFICIAL_CUENTA"` because `"AH_CUENTA"` is the table name and `"REPORTES"` is the schema name

Can I using some as [https://github.com/dremio-hub/dremio-hbase-connector](https://github.com/dremio-hub/dremio-hbase-connector) to build cutom connector that override this wrong column names generated?? which class I should use?

---

<div class="post-metadata">

**Author:** ![ben](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/ben/32/1367_2.png) [@ben](https://community.dremio.com/u/ben)\
**Post date:** [July 28, 2020, 7:10pm UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/3 "2020-07-28T19:10:26Z")

</div>

@dacopan,

Is the source DB2? Unfortunately, we no longer support that connector, so unless a comparable problem presents itself in another officially supported source, I don’t think we can “fix” the pushdown.

---

<div class="post-metadata">

**Author:** ![dacopan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dacopan/32/4289_2.png) [@dacopan](https://community.dremio.com/u/dacopan)\
**Post date:** [July 28, 2020, 7:19pm UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/4 "2020-07-28T19:19:22Z")

</div>

I developed a custom connector that is very madurate we want contributing to dremio with it, all work well only when query to other scheme present this issue,

- in postgres also generated this issue, but postgres doesnt fail because internal driver avoid this wrong names

the questions is:

- using custom connector can i override this wrong columns name generated?
- what changed from 4.0.5 to latest dremio that cause this wrong column names?  
Very thanks by your response

---

<div class="post-metadata">

**Author:** ![dacopan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dacopan/32/4289_2.png) [@dacopan](https://community.dremio.com/u/dacopan)\
**Post date:** [July 29, 2020, 4:17pm UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/5 "2020-07-29T16:17:49Z")

</div>

Thanks @ben, using this explain by @jduong[Push down not work expected](https://community.dremio.com/t/push-down-not-work-expected/5977/8) I fixed the error extending `ArpDialect` and `@Override` hasImplicitTableAlias to false but can you explained me whats is this method? or any documentation about `ArpDialect`?

---

<div class="post-metadata">

**Author:** ![koolay](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/koolay/32/2407_2.png) [@koolay](https://community.dremio.com/u/koolay)\
**Post date:** [July 30, 2020, 8:28am UTC](https://community.dremio.com/t/dremio-generate-wrong-sql/6007/6 "2020-07-30T08:28:28Z")

</div>

@ben

Is there any example about override `JdbcSchemaFetcher`?
