# This import verifies that the dependencies are available.
import pydruid  # noqa: F401

from datahub.configuration.common import AllowDenyPattern

from .sql_common import BasicSQLAlchemyConfig, SQLAlchemySource


class DruidConfig(BasicSQLAlchemyConfig):
    # defaults
    scheme = "druid"
    schema_pattern: AllowDenyPattern = AllowDenyPattern(deny=["^(lookup|sys).*"])

    def get_sql_alchemy_url(self):
        return f"{BasicSQLAlchemyConfig.get_sql_alchemy_url(self)}/druid/v2/sql/"


class DruidSource(SQLAlchemySource):
    def __init__(self, config, ctx):
        super().__init__(config, ctx, "druid")

    @classmethod
    def create(cls, config_dict, ctx):
        config = DruidConfig.parse_obj(config_dict)
        return cls(config, ctx)

@@ -487,16 +487,436 @@
 /sql/%22%0A%0A
+    %22%22%22%0A    The pydruid library already formats the table name correctly, so we do not%0A    need to use the schema name when constructing the URN. Without this override,%0A    every URN would incorrectly start with %22druid.%0A%0A    For more information, see https://druid.apache.org/docs/latest/querying/sql.html#schemata-table%0A%0A    %22%22%22%0A%0A    def get_identifier(self, schema: str, table: str) -%3E str:%0A        return f%22%7Btable%7D%22%0A%0A
 %0Aclass D

Add druid-specific identification logic (#2284)