ããã¯ããªã«ãããããŠæžãããã®ïŒ
Trinoãšããåæ£SQLã¯ãšãªãŒãšã³ãžã³ãè©ŠããŠã¿ãããªãšæãããŸãã¯ã€ã³ã¹ããŒã«ããŠã¿ãããšæããŸãã
Trino | Distributed SQL query engine for big data
ãããããMySQLã«æ¥ç¶ããŠTrinoçµç±ã§ã¢ã¯ã»ã¹ããŠã¿ãŸãããã
Trino
Trinoã®Webãµã€ãããã³GitHubãªããžããªã¯ããã¡ãã§ãã
Trino | Distributed SQL query engine for big data
Trinoã®ããã¥ã¡ã³ãã¯ããã¡ãã
Trino documentation — Trino 392 Documentation
Trinoãšã¯ãªã«ãïŒãšãããšããã§ãããããã¯ããã¥ã¡ã³ãã®ãŠãŒã¹ã±ãŒã¹ã®ããŒãžãèŠãã®ãè¯ãããã§ãã
Use cases — Trino 392 Documentation
Trinoãšã¯ã以äžã®ãããªãã®ã§ãã
- åæ£ã¯ãšãªãŒã䜿çšããŠã倧éã®ããŒã¿ãå¹ççã«æ±ãããã«èšèšãããããŒã«
- HiveãPigãªã©ã®MapReduceãžã§ãã䜿çšããHDFSãžã®ã¯ãšãªãŒãå®è¡ããããŒã«ã®ä»£æ¿ãšããŠéçºãããããTrinoãã¢ã¯ã»ã¹å¯èœãªãã®ã¯HDFSã«éå®ãããªã
- RDBMSãApache Cassandraã®ãããªãæ§ã ãªçš®é¡ã®ããŒã¿ãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãå¯èœ
ããŒã¿ãœãŒã¹ãžã®ã¢ã¯ã»ã¹ã«ã¯ãã³ãã¯ã¿ãŒãšåŒã°ãããã®ã䜿çšããŸãã以äžããã®äžèŠ§ã§ãã
Connectors — Trino 392 Documentation
ãŸããTrinoã¯ä»¥äžã®ãã®ã§ã¯"ãããŸãã"ã
- RDBMSã§ã¯ãªããMySQLãPostgreSQLãOracle Databaseãªã©ã«ä»£ãããã®ã§ã¯ãªã
- OLTPåãã®ããŒã«ã§ã¯ãªã
Trinoã«é¢ããçšèªã¯ããã¡ãã®ããŒãžã«èŒã£ãŠããŸããå°ããã€èªãã§ããããšæããŸãã
Trino concepts — Trino 392 Documentation
ãã¡ããåèã«ã
高性能分散SQLエンジン「Trino」最速ガイド - NTT Communications Engineers' Blog
ãšããã§ããã®ãããªããŒã«ã®ååšã¯Prestoããç¥ããªãã£ãã®ã§ãããTrinoã¯Prestoããåããããã®ã®ããã§ãã
Presto | Distributed SQL Query Engine for Big Data
Prestoã¯Facebookã®éçºè ã«ãã£ãŠäœããããã®ã§ãããã³ã¢ã®éçºè ãã¡ãFacebookãé¢ããŠç«ã¡äžããã®ãTrinoã®ããã§ãã
Trino | We’re rebranding PrestoSQL as Trino
Trino | Why leaving Facebook/Meta was the best thing we could do for the Trino Community
å ã®Prestoã¯PrestoDBãšåŒã³ãæ°ããç«ã¡äžããããæ¹ãPrestoSQLãšåŒã°ããåŸã«Trinoã«ãªã£ãããã§ããã
æåã¯Prestoã䜿ããããªãšæã£ãã®ã§ããããã®Trinoã®æ
å¢ãšJava 17ã§åäœããã®ã¯Trinoã®æ¹ãªã®ã§ãTrinoãè©ŠããŠã¿ããããªãšæããŸãã
åºæ¬çãªèãæ¹ã¯äž¡è
ãšãå€ãããªãããã§ããã
PrestoãJava 16ã17ã§åäœããªããšããissueã
Error : Building/launching Presto with OpenJDK 16 and 17 · Issue #17438 · prestodb/presto · GitHub
ä»åã¯ãTrinoãã€ã³ã¹ããŒã«ããŠMySQLã«ã¢ã¯ã»ã¹ããŠã¿ãããšæããŸãã
ç°å¢
ä»åã®ç°å¢ã¯ããã¡ãã§ãã
ãŸãã¯Trinoãåäœãããç°å¢ã
$ uname -srrvmpio Linux 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal
ãŸããJavaãšPythonãå¿ èŠã§ãã
$ java --version openjdk 17.0.4 2022-07-19 OpenJDK Runtime Environment (build 17.0.4+8-Ubuntu-120.04) OpenJDK 64-Bit Server VM (build 17.0.4+8-Ubuntu-120.04, mixed mode, sharing) $ python -V Python 2.7.18
ãã®ç°å¢ã®IPã¢ãã¬ã¹ã¯ã192.168.0.6
ãšããŸãã
ãŸããMySQLã«ã€ããŠã¯ãã¡ãã
$ mysql --version mysql Ver 8.0.30 for Linux on x86_64 (MySQL Community Server - GPL)
MySQLã¯172.17.0.2
ã§åäœããŠãããã®ãšããæ¥ç¶æ
å ±ã¯kazuhira
ïŒpassword
ã§ãpractice
ãšããããŒã¿ããŒã¹ãäœææžã¿ãšããŸãã
Trinoãã€ã³ã¹ããŒã«ãã
ããã§ã¯ãTrinoãã€ã³ã¹ããŒã«ããŸãããã
ãã¡ãã®ããŒãžã«æ²¿ã£ãŠé²ããŠãããŸãã
Deploying Trino — Trino 392 Documentation
ãªããDockerã€ã¡ãŒãžã䜿ãæ¹æ³ããããŸãããä»åã¯ãµã€ãã«ã€ã³ã¹ããŒã«ããããšã«ããŸãã
Trino in containers — Trino 392 Documentation
Trinoã®ã€ã³ã¹ããŒã«èŠä»¶ã¯ããã¡ãã
Deploying Trino / Requirements
倧ãŸãã«ã¯ã以äžã§ãã
- 64 bit Linux
- ulimitsã調æŽããŠããããš
- Java 17.0.3以é
- ã§ããã°Azul Zuluæšå¥š
- Python 2.6.xã2.7.xã3.xã®ãããã
bin/launcher
ã®ã¿ã§å¿ èŠ
Trinoã®ã€ã³ã¹ããŒã«ã¯ã.tar.gz
ãããŠã³ããŒãããŠ
Deploying Trino / Installing Trino
$ curl -LO https://repo1.maven.org/maven2/io/trino/trino-server/392/trino-server-392.tar.gz
å±éã
$ tar xf trino-server-392.tar.gz
ä»å䜿ãTrinoã®ããŒãžã§ã³ã¯ã392ã§ããã
ãã£ã¬ã¯ããªå ã«ç§»åã
$ cd trino-server-392
ãã£ã¬ã¯ããªæ§æã¯ãããªæãã«ãªã£ãŠãããã³ãã¯ã¿ãŒã¯ãã©ã°ã€ã³ãšããŠå«ãŸããŠããããã§ãã
$ tree -d . âââ bin â  âââ procname â  âââ Linux-aarch64 â  âââ Linux-ppc64le â  âââ Linux-x86_64 âââ lib âââ plugin âââ accumulo âââ atop âââ bigquery âââ blackhole âââ cassandra âââ clickhouse âââ delta-lake âââ druid âââ elasticsearch âââ example-http âââ exchange-filesystem âââ geospatial âââ google-sheets âââ hive âââ http-event-listener âââ iceberg âââ jmx âââ kafka âââ kinesis âââ kudu âââ local-file âââ mariadb âââ memory âââ ml âââ mongodb âââ mysql âââ oracle âââ password-authenticators âââ phoenix5 âââ pinot âââ postgresql âââ prometheus âââ raptor-legacy âââ redis âââ redshift âââ resource-group-managers âââ session-property-managers âââ singlestore âââ sqlserver âââ teradata-functions âââ thrift âââ tpcds âââ tpch 50 directories
bin
ãã£ã¬ã¯ããªã®äžã¯ããããªæãã§ãã
$ tree bin bin âââ launcher âââ launcher.properties âââ launcher.py âââ procname âââ Linux-aarch64 â  âââ libprocname.so âââ Linux-ppc64le â  âââ libprocname.so âââ Linux-x86_64 âââ libprocname.so 4 directories, 6 files
次ã«ãTrinoã®èšå®ãè¡ããŸãã
Deploying Trino / Configuring Trino
ã€ã³ã¹ããŒã«ãã£ã¬ã¯ããªå
ã«ãetc
ãšãããã£ã¬ã¯ããªãäœæããå¿
èŠãããããã§ãã
Create an etc directory inside the installation directory.
$ mkdir etc
ãã®äžã«ã¯ã以äžã®èšå®ãå«ããããã§ãã
- ããŒãã®èšå®
- Java VMã®èšå®
- Trinoã®èšå®
- ã³ãã¯ã¿ãŒã®èšå®
æºåè¡ã£ãŠãããŸãããã
ããŒãã®èšå®ã
Deploying Trino / Configuring Trino / Node properties
ããŒãã®èšå®ã§ã¯ãããŒã¿ãã£ã¬ã¯ããªãå¿
èŠããããã€ã³ã¹ããŒã«ãã£ã¬ã¯ããªå€ã«äœæããããšãæšå¥šããŠãããããªã®ã§ããšãããã
ããäžã®ãã£ã¬ã¯ããªã«äœæããŠãããŸãããã
$ mkdir ../data
èšå®ã¯ããããªæãã«ããŸããã
etc/node.properties
node.environment=my_trino node.id=340fae6b-55fe-486e-b122-d0fbe61d0ebb node.data-dir=../data
ç¶ããŠãJava VMã®èšå®ã
Deploying Trino / Configuring Trino / JVM config
etc/jvm.config
-server -Xmx4G -XX:InitialRAMPercentage=80 -XX:MaxRAMPercentage=80 -XX:G1HeapRegionSize=32M -XX:+ExplicitGCInvokesConcurrent -XX:+ExitOnOutOfMemoryError -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:ReservedCodeCacheSize=512M -XX:PerMethodRecompilationCutoff=10000 -XX:PerBytecodeRecompilationCutoff=10000 -Djdk.attach.allowAttachSelf=true -Djdk.nio.maxCachedBufferSize=2000000 -XX:+UnlockDiagnosticVMOptions -XX:+UseAESCTRIntrinsics
æŠãããã¥ã¡ã³ãéããªã®ã§ãããããŒãã®æ倧å€ã®ã¿äžããŠãããŸããããããªã«ããããã¡ã¢ãªãæã£ãç°å¢ã§å®è¡ããŠããªãã®ã§ã
Trinoã®èšå®ã
Deploying Trino / Configuring Trino / Config properties
ä»åã¯ãã³ãŒãã£ããŒã¿ãŒå Œã¯ãŒã«ãŒãšããããšã«ããŸãã
etc/config.properties
coordinator=true node-scheduler.include-coordinator=true http-server.http.port=8080 discovery.uri=http://192.168.0.6:8080
ã³ãŒãã£ããŒã¿ãŒããã³ã¯ãŒã«ãŒã«ã€ããŠã¯ããã¡ãã«èª¬æããããŸãã
ã³ãŒãã£ããŒã¿ãŒã¯ãã¹ããŒãã¡ã³ãã®è§£æãã¯ãšãªãŒã®èšç»ãã¯ãŒã«ãŒã®ç®¡çãè¡ããµãŒããŒã§ãã
ã¯ãŒã«ãŒã¯ã¿ã¹ã¯ã®å®è¡ãšããŒã¿ã®åŠçãè¡ããµãŒããŒã§ãã
ä»åã®èšå®ã§ã¯coordinator
ãtrue
ãšããŠã³ãŒãã£ããŒã¿ãŒã§ãããšããèšå®ãè¡ããnode-scheduler.include-coordinator
ãtrue
ãšããããšã§
ã³ãŒãã£ããŒã¿ãŒå
ã§äœæ¥ã®ã¹ã±ãžã¥ãŒãªã³ã°ãè¡ãããšãèš±å¯ããŸãã
ã€ãŸããã³ãŒãã£ããŒã¿ãŒå Œã¯ãŒã«ãŒã§ãã
ãã¹ãç®çã§ã¯äž¡æ¹ã®ãµãŒããŒãåå± ãããããšãããããã§ãããéåžžã®éçšã ãšå¥åã®ç®¡çã«ããã¿ããã§ããã
ã³ãã¯ã¿ãŒã®èšå®ã
Deploying Trino / Configuring Trino / Catalog properties
etc/catalog
ãã£ã¬ã¯ããªãäœæããŸãã
$ mkdir etc/catalog
ãã®ãã£ã¬ã¯ããªå
ã«ã[ã«ã¿ãã°å].properties
ã§ãã¡ã€ã«ãäœæããŸããå
容ã¯ãåã³ãã¯ã¿ãŒã®ããã¥ã¡ã³ããåç
§ããŸãã
MySQLã®å Žåã¯ããã¡ãã
MySQL connector — Trino 392 Documentation
etc/catalog/mysql.properties
connector.name=mysql connection-url=jdbc:mysql://172.17.0.2:3306 connection-user=kazuhira connection-password=password
ã³ãã¯ã¿ãŒãšããã®ã¯ãRDBMSãHiveãªã©ã®ããŒã¿ãœãŒã¹ã«æ¥ç¶ããããã®ãã©ã€ããŒã«çžåœãããã®ã§ãã
Trino concepts / Data sources / Connector
ãããŠãã³ãã¯ã¿ãŒã«é¢é£ä»ããããŠããã®ãã«ã¿ãã°ã§ãã
Trino concepts / Data sources / Catalog
Trinoã§SQLã¹ããŒãã¡ã³ããå®è¡ãããšãã²ãšã€ä»¥äžã®ã«ã¿ãã°ã«å¯ŸããŠå®è¡ãããã³ãã¯ã¿ãŒãä»ããŠããŒã¿ãœãŒã¹ã«æ¥ç¶ããŸãã
ãããŸã§ã§æäœéã®æºåãã§ããã®ã§ãTrinoãèµ·åãããŸãã
Deploying Trino / Running Trino
ãŸãã¯ãã«ãã確èªã
$ bin/launcher --help Usage: launcher [options] command Commands: run, start, stop, restart, kill, status Options: -h, --help show this help message and exit -v, --verbose Run verbosely --etc-dir=DIR Defaults to INSTALL_PATH/etc --launcher-config=FILE Defaults to INSTALL_PATH/bin/launcher.properties --node-config=FILE Defaults to ETC_DIR/node.properties --jvm-config=FILE Defaults to ETC_DIR/jvm.config --config=FILE Defaults to ETC_DIR/config.properties --log-levels-file=FILE Defaults to ETC_DIR/log.properties --data-dir=DIR Defaults to INSTALL_PATH --pid-file=FILE Defaults to DATA_DIR/var/run/launcher.pid --launcher-log-file=FILE Defaults to DATA_DIR/var/log/launcher.log (only in daemon mode) --server-log-file=FILE Defaults to DATA_DIR/var/log/server.log (only in daemon mode) -J OPT Set a JVM option -D NAME=VALUE Set a Java system property
status
ã³ãã³ãã§ãTrinoã®ã¹ããŒã¿ã¹ã確èªã
$ bin/launcher status --verbose config_path = /path/to/trino-server-392/etc/config.properties data_dir = /path/to/data etc_dir = /path/to/trino-server-392/etc install_path = /path/to/trino-server-392 jvm_config = /path/to/trino-server-392/etc/jvm.config jvm_options = [] launcher_config = /path/to/trino-server-392/bin/launcher.properties launcher_log = /path/to/data/var/log/launcher.log log_levels = /path/to/trino-server-392/etc/log.properties log_levels_set = False node_config = /path/to/trino-server-392/etc/node.properties pid_file = /path/to/data/var/run/launcher.pid properties = {'node.environment': 'my_trino', 'node.data-dir': '../data', 'node.id': '340fae6b-55fe-486e-b122-d0fbe61d0ebb'} server_log = /path/to/data/var/log/server.log verbose = True Not running
Trinoã®å®è¡ã¯ãstart
ãŸãã¯run
ã§è¡ããŸããstart
ãããŒã¢ã³å®è¡ã§ããã©ã¢ã°ã©ãŠã³ãã§å®è¡ããã®ãrun
ã§ããã
ä»åã¯ãrun
ã§èµ·åããŠã¿ãããšã«ããŸãã
$ bin/launcher run
ããã§ãTrinoãèµ·åããŸããã
Trino CLIã䜿ã£ãŠã¢ã¯ã»ã¹ããŠã¿ã
次ã«ãTrinoã«ã¯ã©ã€ã¢ã³ãããã¢ã¯ã»ã¹ããŠã¿ãŸãããã
Clients — Trino 392 Documentation
ãªãã£ã·ã£ã«ã«ã¯CLIãšJDBCãã©ã€ããŒãããããã§ãã
Command line interface — Trino 392 Documentation
JDBC driver — Trino 392 Documentation
ãµãŒãããŒãã£è£œã®ã¯ã©ã€ã¢ã³ããå«ããäžèŠ§ã¯ããã¡ãã
ä»åã¯CLIã䜿ãããšã«ããŸãã
Command line interface — Trino 392 Documentation
CLIã䜿ãã«ã¯ãJava 8以äžãã€ã³ã¹ããŒã«ãããŠããã°ããã¿ããã§ãã
Command line interface / Requirements
ãŸããCLIã¯Trinoã«HTTPãŸãã¯HTTPSã§ã®REST APIã§ã¢ã¯ã»ã¹ããããã§ãã
ã€ã³ã¹ããŒã«ã
Command line interface / Installation
$ curl -LO https://repo1.maven.org/maven2/io/trino/trino-cli/392/trino-cli-392-executable.jar
ååŸããJARãã¡ã€ã«ããªããŒã ããŠãå®è¡æš©éãä»äžããŸãã
$ mv trino-cli-392-executable.jar trino $ chmod +x trino
ããŒãžã§ã³ã®ç¢ºèªã
$ ./trino --version Trino CLI 392
ãã«ãã
$ ./trino --help Trino command line interface USAGE: trino [-h] [--debug] [--disable-auto-suggestion] [--disable-compression] [--external-authentication] [--ignore-errors] [--insecure] [--krb5-disable-remote-service-hostname-canonicalization] [--password] [--[no-]progress] [--use-system-truststore] [--version] [--access-token=<token>] [--catalog=<catalog>] [--client-info=<info>] [--client-request-timeout=<timeout>] [--client-tags=<tags>] [--editing-mode=<editing-mode>] [--execute=<execute>] [-f=<file>] [--http-proxy=<proxy>] [--keystore-password=<password>] [--keystore-path=<path>] [--keystore-type=<type>] [--krb5-config-path=<path>] [--krb5-credential-cache-path=<path>] [--krb5-keytab-path=<path>] [--krb5-principal=<principal>] [--krb5-remote-service-name=<name>] [--krb5-service-principal-pattern=<pattern>] [--network-logging=<level>] [--output-format=<format>] [--schema=<schema>] [--server=<server>] [--session-user=<user>] [--socks-proxy=<proxy>] [--source=<source>] [--timezone=<timezone>] [--trace-token=<token>] [--truststore-password=<password>] [--truststore-path=<path>] [--truststore-type=<type>] [--user=<user>] [--external-authentication-redirect-handler=<externalAuthenticationRedirectHandler>]... [--extra-credential=<credential>]... [--resource-estimate=<estimate>]... [--session=<session>]... OPTIONS: --access-token=<token> Access token --catalog=<catalog> Default catalog --client-info=<info> Extra information about client making query --client-request-timeout=<timeout> Client request timeout (default: 2m) --client-tags=<tags> Client tags --debug Enable debug information --disable-auto-suggestion Disable auto suggestion --disable-compression Disable compression of query results --editing-mode=<editing-mode> Editing mode [EMACS, VI] (default: EMACS) --execute=<execute> Execute specified statements and exit --external-authentication Enable external authentication --external-authentication-redirect-handler=<externalAuthenticationRedirectHandler> External authentication redirect handlers: DESKTOP_OPEN, SYSTEM_OPEN, PRINT, OPEN, ALL (default: ALL) --extra-credential=<credential> Extra credentials (property can be used multiple times; format is key=value) -f, --file=<file> Execute statements from file and exit -h, --help Show this help message and exit --http-proxy=<proxy> HTTP proxy to use for server connections --ignore-errors Continue processing in batch mode when an error occurs (default is to exit immediately) --insecure Skip validation of HTTP server certificates (should only be used for debugging) --keystore-password=<password> Keystore password --keystore-path=<path> Keystore path --keystore-type=<type> Keystore type --krb5-config-path=<path> Kerberos config file path (default: /etc/krb5.conf) --krb5-credential-cache-path=<path> Kerberos credential cache path --krb5-disable-remote-service-hostname-canonicalization Disable service hostname canonicalization using the DNS reverse lookup --krb5-keytab-path=<path> Kerberos key table path (default: /etc/krb5.keytab) --krb5-principal=<principal> Kerberos principal to be used --krb5-remote-service-name=<name> Remote peer's kerberos service name --krb5-service-principal-pattern=<pattern> Remote kerberos service principal pattern (default: ${SERVICE}@${HOST}) --network-logging=<level> Network logging level [NONE, BASIC, HEADERS, BODY] (default: NONE) --output-format=<format> Output format for batch mode [ALIGNED, VERTICAL, TSV, TSV_HEADER, CSV, CSV_HEADER, CSV_UNQUOTED, CSV_HEADER_UNQUOTED, JSON, NULL] (default: CSV) --password Prompt for password --[no-]progress Show query progress --resource-estimate=<estimate> Resource estimate (property can be used multiple times; format is key=value) --schema=<schema> Default schema --server=<server> Trino server location (default: localhost:8080) --session=<session> Session property (property can be used multiple times; format is key=value; use 'SHOW SESSION' to see available properties) --session-user=<user> Username to impersonate --socks-proxy=<proxy> SOCKS proxy to use for server connections --source=<source> Name of source making query (default: trino-cli) --timezone=<timezone> Session time zone (default: Asia/Tokyo) --trace-token=<token> Trace token --truststore-password=<password> Truststore password --truststore-path=<path> Truststore path --truststore-type=<type> Truststore type --use-system-truststore Use default system (OS) truststore --user=<user> Username (default: xxxxx) --version Print version information and exit
ã§ã¯ãCLIã䜿ã£ãŠTrinoã«æ¥ç¶ããŸãã
Command line interface / Running the CLI
--server
ã§æ¥ç¶å
ã®Trinoãæå®ããã®ã§ãããããã©ã«ãå€ã¯localhost:8080
ã§ãã
ä»åã¯TrinoãšCLIãåããµãŒããŒäžã§åäœãããŠããã®ã§ã以äžã®ãããã§ãæ¥ç¶å¯èœã§ãã
$ ./trino $ ./trino --server localhost:8080 $ ./trino --server 192.168.0.6:8080
æ¥ç¶ãããšãããã³ãããçŸããŸãã
trino>
ããã§ãããŒãã«ã«ã¢ã¯ã»ã¹ããã«ã¯[ã«ã¿ãã°å].[ã¹ããŒãåïŒããŒã¿ããŒã¹åïŒ].[ããŒãã«å]
ã«ãªãããã§ãã
If the Hive connector is mounted as the hive catalog, and Hive contains a table clicks in database web, that table can be accessed in Trino as hive.web.clicks.
Deploying Trino / Configuring Trino / Catalog properties
MySQL Connectorã®ããã¥ã¡ã³ããèŠãŠã¿ãŸãããã
MySQL connector — Trino 392 Documentation
æ¥ç¶å¯èœãªMySQLã®ããŒãžã§ã³ã¯ã5.7ã8.0以éã®ããã§ãã
MySQL connector / Requirements
MySQLã®ããŒã¿åãšãTrinoã®ããŒã¿åã®ãããã³ã°ã¯ãã¡ãã
MySQL connector / Type mapping
ã¯ãšãªãŒã®äŸã
MySQL connector / Querying MySQL
䜿çšã§ãããµããŒããããŠããSQLã¯ã以äžã®2ã€ã§ãªã¹ãã¢ãããããŠãããã®ã«å ããŠ
以äžã®ããã§ãã
INSERT
DELETE
TRUNCATE
CREATE TABLE
CREATE TABLE AS
DROP TABLE
CREATE SCHEMA
DROP SCHEMA
Trinoã®SQLã«é¢ããããã¥ã¡ã³ãã¯ããã¡ãã
SQL language — Trino 392 Documentation
ãã£ãããªã®ã§ãTrinoçµç±ã§MySQLã«ããŒãã«ãäœæãããããŠæäœããŠã¿ãŸãããã
ããŒã¿ããŒã¹å ã®ããŒãã«äžèŠ§ã
trino> show tables from mysql.practice; Table ------- (0 rows) Query 20220810_151108_00002_qc4ed, FINISHED, 1 node Splits: 7 total, 7 done (100.00%) 1.70 [0 rows, 0B] [0 rows/s, 0B/s]
ãŸã ããŒãã«ããªãã®ã§ããã
ããŒãã«ãäœæããŠã¿ãŸãããã
trino> create table mysql.practice.person(id integer, first_name varchar(255), last_name varchar(255)); CREATE TABLE
CREATE TABLE — Trino 392 Documentation
ããŒãã«ãã§ããŸããã
trino> show tables from mysql.practice; Table -------- person (1 row) Query 20220810_151931_00006_qc4ed, FINISHED, 1 node Splits: 7 total, 7 done (100.00%) 0.54 [1 rows, 24B] [1 rows/s, 45B/s]
ããŒã¿ãç»é²ããŠã¿ãŸãã
trino> insert into mysql.practice.person(id, first_name, last_name) values(1, 'ã«ããª', '磯é'); INSERT: 1 row Query 20220810_152128_00007_qc4ed, FINISHED, 1 node Splits: 11 total, 11 done (100.00%) 0.95 [0 rows, 0B] [0 rows/s, 0B/s] trino> insert into mysql.practice.person(id, first_name, last_name) values(2, 'ã¯ã«ã¡', '磯é'); INSERT: 1 row Query 20220810_152152_00008_qc4ed, FINISHED, 1 node Splits: 11 total, 11 done (100.00%) 0.71 [0 rows, 0B] [0 rows/s, 0B/s] trino> insert into mysql.practice.person(id, first_name, last_name) values(3, 'ã¿ã©ãª', 'ãã°ç°'); INSERT: 1 row Query 20220810_152242_00009_qc4ed, FINISHED, 1 node Splits: 11 total, 11 done (100.00%) 0.52 [0 rows, 0B] [0 rows/s, 0B/s]
INSERT — Trino 392 Documentation
ããŒã¿ã®ååŸã
trino> select * from mysql.practice.person order by id; id | first_name | last_name ----+------------+----------- 1 | ã«ã㪠| 磯é 2 | ã¯ã«ã¡ | 磯é 3 | ã¿ã©ãª | ãã°ç° (3 rows) Query 20220810_152400_00012_qc4ed, FINISHED, 1 node Splits: 7 total, 7 done (100.00%) 0.21 [3 rows, 0B] [14 rows/s, 0B/s]
SELECT — Trino 392 Documentation
ã³ãã¯ã¿ãŒã«ãã£ãŠã¯ãã©ã³ã¶ã¯ã·ã§ã³ã䜿ãããããªã®ã§ãè©ŠããŠã¿ãŸãããã
SQL statement support / Transactions
ãã©ã³ã¶ã¯ã·ã§ã³ãéå§ã
trino> start transaction; START TRANSACTION
START TRANSACTION — Trino 392 Documentation
insert
ãå®è¡ããŠã¿ãŸãããã
trino> insert into mysql.practice.person(id, first_name, last_name) values(4, 'ãµã¶ãš', 'ãã°ç°'); Query 20220810_152706_00014_qc4ed failed: Catalog only supports writes using autocommit: mysql
ãã¡ã§ããã
ãããããã®ããšselec
æãæããããªããªããŸãã
trino> select * from mysql.practice.person order by id; Query 20220810_153307_00021_qc4ed failed: Current transaction is aborted, commands ignored until end of transaction block
trino> rollback; ROLLBACK
ROLLBACK — Trino 392 Documentation
ãµã€ãã«ç»é²ããŸãããâŠã
trino> insert into mysql.practice.person(id, first_name, last_name) values(4, 'ãµã¶ãš', 'ãã°ç°'); INSERT: 1 row Query 20220810_153608_00023_qc4ed, FINISHED, 1 node Splits: 11 total, 11 done (100.00%) 0.61 [0 rows, 0B] [0 rows/s, 0B/s] trino> insert into mysql.practice.person(id, first_name, last_name) values(5, 'ãã¹ãª', 'ãã°ç°'); INSERT: 1 row Query 20220810_153613_00024_qc4ed, FINISHED, 1 node Splits: 11 total, 11 done (100.00%) 0.54 [0 rows, 0B] [0 rows/s, 0B/s]
確èªã
trino> select * from mysql.practice.person order by id; id | first_name | last_name ----+------------+----------- 1 | ã«ã㪠| 磯é 2 | ã¯ã«ã¡ | 磯é 3 | ã¿ã©ãª | ãã°ç° 4 | ãµã¶ãš | ãã°ç° 5 | ãã¹ãª | ãã°ç° (5 rows) Query 20220810_153630_00025_qc4ed, FINISHED, 1 node Splits: 7 total, 7 done (100.00%) 0.23 [5 rows, 0B] [22 rows/s, 0B/s]
äžå¿ãMySQLåŽã§ã確èªããŠã¿ãŸãã
mysql> select * from person order by id; +------+------------+-----------+ | id | first_name | last_name | +------+------------+-----------+ | 1 | ã«ã㪠| 磯é | | 2 | ã¯ã«ã¡ | 磯é | | 3 | ã¿ã©ãª | ãã°ç° | | 4 | ãµã¶ãš | ãã°ç° | | 5 | ãã¹ãª | ãã°ç° | +------+------------+-----------+ 5 rows in set (0.00 sec)
OKã§ããã
ããšããããŸã§ãã£ãš[ã«ã¿ãã°å].[ã¹ããŒãåïŒããŒã¿ããŒã¹åïŒ].[ããŒãã«å]
ãä»ããŠããŸããããuse
ã䜿ãããšã§çŸåšã®
ã¹ããŒãïŒããŒã¿ããŒã¹ïŒãæå®ã§ãããããªã®ã§æåŸã«è©ŠããŠã¿ãŸãã
trino> use mysql.practice; USE
ããã³ãããå€ãããŸãã
trino:practice> use mysql.practice; USE
ããŒãã«åãçŽæ¥æå®ããŠã¿ãŸãããã
trino:practice> select * from person order by id; id | first_name | last_name ----+------------+----------- 1 | ã«ã㪠| 磯é 2 | ã¯ã«ã¡ | 磯é 3 | ã¿ã©ãª | ãã°ç° 4 | ãµã¶ãš | ãã°ç° 5 | ãã¹ãª | ãã°ç° (5 rows) Query 20220810_154405_00029_qc4ed, FINISHED, 1 node Splits: 7 total, 7 done (100.00%) 0.18 [5 rows, 0B] [28 rows/s, 0B/s]
ã«ã¿ãã°åãã¹ããŒãåãæå®ããã«ããŒãã«ã解決ã§ããŸãããã
use
ã¯ãã«ã¿ãã°åãšã¹ããŒãåã®äž¡æ¹ãæå®ããããã¹ããŒãåã®ã¿ãæå®ããŠå©çšããããã§ãã
trino:practice> use practice; USE
ã«ã¿ãã°åãæå®ãããã¹ããŒãåã®ã¿ãæå®ããå Žåã¯ãçŸåšã®ã«ã¿ãã°ãã解決å¯èœãªããŒã¿ããŒã¹ãéžæããããã§ãã
ä»åã¯ããããªãšããã«ããŠãããŸãããã
ãŸãšã
åæ£SQLã¯ãšãªãŒãšã³ãžã³ã§ãããTrinoãè©ŠããŠã¿ãŸããã
ãã£ãããã£ãããšäœ¿ããŠé¢çœããªãšæããŸãããããããããããè©ŠããŠã¿ãŸãããã