* Trino fix #705

* Update trino.json to point to default database
This commit is contained in:
Ayush Shah 2021-10-08 00:55:03 +05:30 committed by GitHub
parent 28e1d2977b
commit a19c5bceca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -3,8 +3,8 @@
"type": "trino", "type": "trino",
"config": { "config": {
"service_name": "local_trino", "service_name": "local_trino",
"host_port": "192.168.1.32:8080", "host_port": "localhost:8080",
"database": "default" "catalog": "system"
} }
}, },
"sink": { "sink": {

View File

@ -12,6 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import Optional
from urllib.parse import quote_plus from urllib.parse import quote_plus
from .sql_source import SQLSource, SQLConnectionConfig from .sql_source import SQLSource, SQLConnectionConfig
@ -22,6 +23,8 @@ class TrinoConfig(SQLConnectionConfig):
host_port = "localhost:8080" host_port = "localhost:8080"
scheme = "trino" scheme = "trino"
service_type = "Trino" service_type = "Trino"
catalog: str
schema_name: Optional[str]
def get_connection_url(self): def get_connection_url(self):
url = f"{self.scheme}://" url = f"{self.scheme}://"
@ -30,8 +33,10 @@ class TrinoConfig(SQLConnectionConfig):
if self.password: if self.password:
url += f":{quote_plus(self.password)}" url += f":{quote_plus(self.password)}"
url += f"{self.host_port}" url += f"{self.host_port}"
if self.database: if self.catalog:
url += f"?schema={quote_plus(self.database)}" url += f"/{quote_plus(self.catalog)}"
if self.schema_name:
url += f"/{quote_plus(self.schema_name)}"
return url return url