aadel / sqlalchemy-solr

Apache Solr dialect for SQLAlchemy
MIT License
9 stars 7 forks source link

Issue while creating chart for Solr #14

Open rohitpawar2811 opened 10 months ago

rohitpawar2811 commented 10 months ago

This query is generated by Superset and is causing errors. After fetching data, we prepare columns and types in the SolrTableReflection class.

However, in the logic for extracting tables, it extracts the name of the alias ['virtual_table']. Subsequently, using the alias name, it calls the /admin/luke API and encounters an error because there is no collection available with the alias virtual_table.

The problematic query is:

SELECT pd AS pd,
       pn AS pn
FROM
  (SELECT productId AS pd,
          productName AS pn
   FROM enterpriseSearch) AS virtual_table
LIMIT 10;
rohitpawar2811 commented 10 months ago

@aadel Solution: I believe we need to modify the table-extracting logic in SolrTableReflection so that it extracts the table_name after the FROM clause, rather than the alias name. This adjustment will help prevent this error.

rohitpawar2811 commented 10 months ago

Can you explain the exact use case of the SolrTableReflection class and why we are iterating over tables here? In the case of a simple SELECT * FROM table_name, we wouldn't iterate over the loop. Are we handling aliases or Cross Join support use case

for table in tables: if table not in SolrTableReflection.table_metadata_cache: session = SolrTableReflection.connection._session

aadel commented 10 months ago

Solution: I believe we need to modify the table-extracting logic in SolrTableReflection so that it extracts the table_name after the FROM clause, rather than the alias name. This adjustment will help prevent this error.

Hi @rohitpawar2811 Yes, I think this relates to issue #16 since the library does not currently support Solr aliases.