Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page
Help Center/ MapReduce Service/ Service Overview/ Components/ Spark2x/ Optimizing Spark SQL Query of Data of Multiple Sources

Optimizing Spark SQL Query of Data of Multiple Sources

Updated on 2024-12-10 GMT+08:00

Scenario

Enterprises usually store massive data, such as from various databases and warehouses, for management and information collection. However, diversified data sources, hybrid dataset structures, and scattered data storage lower query efficiency.

The open source Spark only supports simple filter pushdown during querying of multi-source data. The SQL engine performance is deteriorated due of a large amount of unnecessary data transmission. The pushdown function is enhanced, so that aggregate, complex projection, and complex predicate can be pushed to data sources, reducing unnecessary data transmission and improving query performance.

Only the JDBC data source supports pushdown of query operations, such as aggregate, projection, predicate, aggregate over inner join, and aggregate over union all. All pushdown operations can be enabled based on your requirements.

Table 1 Enhanced query of cross-source query

Module

Before Enhancement

After Enhancement

aggregate

The pushdown of aggregate is not supported.

  • Aggregation functions including sum, avg, max, min, and count are supported.

    Example: select count(*) from table

  • Internal expressions of aggregation functions are supported.

    Example: select sum(a+b) from table

  • Calculation of aggregation functions is supported. Example: select avg(a) + max(b) from table
  • Pushdown of having is supported.

    Example: select sum(a) from table where a>0 group by b having sum(a)>10

  • Pushdown of some functions is supported.

    Pushdown of lines in mathematics, time, and string functions, such as abs(), month(), and length() are supported. In addition to the preceding built-in functions, you can run the SET command to add functions supported by data sources.

    Example: select sum(abs(a)) from table

  • Pushdown of limit and order by after aggregate is supported. However, the pushdown is not supported in Oracle, because Oracle does not support limit.

    Example: select sum(a) from table where a>0 group by b order by sum(a) limit 5

projection

Only pushdown of simple projection is supported. Example: select a, b from table

  • Complex expressions can be pushed down.

    Example: select (a+b)*c from table

  • Some functions can be pushed down. For details, see the description below the table.

    Example: select length(a)+abs(b) from table

  • Pushdown of limit and order by after projection is supported.

    Example: select a, b+c from table order by a limit 3

predicate

Only simple filtering with the column name on the left of the operator and values on the right is supported. Example:

select * from table where a>0 or b in ("aaa", "bbb")

  • Complex expression pushdown is supported.

    Example: select * from table where a+b>c*d or a/c in (1, 2, 3)

  • Some functions can be pushed down. For details, see the description below the table.

    Example: select * from table where length(a)>5

aggregate over inner join

Related data from the two tables must be loaded to Spark. The join operation must be performed before the aggregate operation.

The following functions are supported:

  • Aggregation functions including sum, avg, max, min, and count are supported.
  • All aggregate operations can be performed in a same table. The group by operations can be performed on one or two tables and only inner join is supported.

The following scenarios are not supported:

  • aggregate cannot be pushed down from both the left- and right-join tables.
  • aggregate contains operations, for example, sum(a+b).
  • aggregate operations, for example, sum(a)+min(b).

aggregate over union all

Related data from the two tables must be loaded to Spark. union must be performed before aggregate.

Supported scenarios:

Aggregation functions including sum, avg, max, min, and count are supported.

Unsupported scenarios:

  • aggregate contains operations, for example, sum(a+b).
  • aggregate operations, for example, sum(a)+min(b).

Precautions

  • If external data source is Hive, query operation cannot be performed on foreign tables created by Spark.
  • Only MySQL and MPPDB data sources are supported.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback