Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
Presto实战
by
Matt Fuller
,
Manfred Moser
,
Martin Traverso
March 2021
Intermediate to advanced
265 pages
6h 50m
Chinese
Posts & Telecom Press
Content preview from
Presto实战
高级
SQL
特性
|
149
单目运算符
单目运算符接收单个操作数的输入,并产生一个单值结果。与双目运算符一样,运算符
指定了操作数的数据类型必须是什么,结果的数据类型必须是什么。单目运算符写作
运
算符操作数
。
对于双目运算符和单目运算符,输入的操作数可以是一个运算符树运算的结果。例如,在
2
×
2
×
2
中,第一个运算符
2
×
2
的结果被输入第二个乘法运算符中。
在本章的以下几节中,你将详细了解
Presto
所支持的众多函数和运算符。
9.2
标量函数和运算符
抽象地讲,
SQL
中的标量函数将一个或多个单值作为输入参数,根据输入的参数执行一个
操作,然后产生一个单值。例如
power(x
,
p)
函数返回
x
的
p
次幂。
SELECT power(2, 3);
_col0
-------
8.0
(1 row)
当然,你可以用乘法运算符来实现同样的目的,在本例中,
2
×
2
×
2
也会产生值
8
。但是,
使用函数可以将逻辑封装起来,使其更容易在
SQL
中重复使用
。此外,还能得到其他收
益,比如减少出错的可能和优化函数的执行。
只要在语义正确,标量函数可以用在
SQL
语句中任何可以使用表达式的地方。例如,
你可
以写一个
SQL
查询
SELECT * FROM page_views WHERE power(2, 3)
。它可以通过语法检查,
但在语义分析时会失败,因为
power
函数的返回类型是
DOUBLE
而不是所需的
BOOLEAN
类
型。可以将
SQL
查询写成
SELECT * FROM page_views WHERE power(2, 3) = 8
,虽然它可 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial
You might also like
大数据项目管理:从规划到实现
Ted Malaska, Jonathan Seidman
数据库系统内幕
Alex Petrov
云原生:运用容器、函数计算和数据构建下一代应用
Boris Scholl, Trent Swanson, Peter Jausovec
Google系统架构解密: 构建安全可靠的系统
Heather Adkins, Betsy Beyer, Paul Blankinship, Piotr Lewandowski, Ana Oprea, Adam Stubblefield
Publisher Resources
ISBN: 9787115560056