-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtypes.html
107 lines (94 loc) · 5.46 KB
/
types.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>10.4. Types — Presto 0.212 Documentation</title>
<link rel="stylesheet" href="../_static/presto.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.212',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="top" title="Presto 0.212 Documentation" href="../index.html" />
<link rel="up" title="10. Developer Guide" href="../develop.html" />
<link rel="next" title="10.5. Functions" href="functions.html" />
<link rel="prev" title="10.3. Example HTTP Connector" href="example-http.html" />
</head>
<body role="document">
<div class="header">
<h1 class="heading"><a href="../index.html">
<span>Presto 0.212 Documentation</span></a></h1>
<h2 class="heading"><span>10.4. Types</span></h2>
</div>
<div class="topnav">
<p class="nav">
<span class="left">
« <a href="example-http.html">10.3. Example HTTP Connector</a>
</span>
<span class="right">
<a href="functions.html">10.5. Functions</a> »
</span>
</p>
</div>
<div class="content">
<div class="section" id="types">
<h1>10.4. Types</h1>
<p>The <code class="docutils literal"><span class="pre">Type</span></code> interface in Presto is used to implement a type in the SQL language.
Presto ships with a number of built-in types, like <code class="docutils literal"><span class="pre">VarcharType</span></code> and <code class="docutils literal"><span class="pre">BigintType</span></code>.
The <code class="docutils literal"><span class="pre">ParametricType</span></code> interface is used to provide type parameters for types, to
allow types like <code class="docutils literal"><span class="pre">VARCHAR(10)</span></code> or <code class="docutils literal"><span class="pre">DECIMAL(22,</span> <span class="pre">5)</span></code>. A <code class="docutils literal"><span class="pre">Plugin</span></code> can provide
new <code class="docutils literal"><span class="pre">Type</span></code> objects by returning them from <code class="docutils literal"><span class="pre">getTypes()</span></code> and new <code class="docutils literal"><span class="pre">ParametricType</span></code>
objects by returning them from <code class="docutils literal"><span class="pre">getParametricTypes()</span></code>.</p>
<p>Below is a high level overview of the <code class="docutils literal"><span class="pre">Type</span></code> interface, for more details see the
JavaDocs for <code class="docutils literal"><span class="pre">Type</span></code>.</p>
<ul>
<li><p class="first">Native container type:</p>
<p>All types define the <code class="docutils literal"><span class="pre">getJavaType()</span></code> method, frequently referred to as the
“native container type”. This is the Java type used to hold values during execution
and to store them in a <code class="docutils literal"><span class="pre">Block</span></code>. For example, this is the type used in
the Java code that implements functions that produce or consume this <code class="docutils literal"><span class="pre">Type</span></code>.</p>
</li>
<li><p class="first">Native encoding:</p>
<p>The interpretation of a value in its native container type form is defined by its
<code class="docutils literal"><span class="pre">Type</span></code>. For some types, such as <code class="docutils literal"><span class="pre">BigintType</span></code>, it matches the Java
interpretation of the native container type (64bit 2’s complement). However, for other
types such as <code class="docutils literal"><span class="pre">TimestampWithTimeZoneType</span></code>, which also uses <code class="docutils literal"><span class="pre">long</span></code> for its
native container type, the value stored in the <code class="docutils literal"><span class="pre">long</span></code> is a 8byte binary value
combining the timezone and the milliseconds since the unix epoch. In particular,
this means that you cannot compare two native values and expect a meaningful
result, without knowing the native encoding.</p>
</li>
<li><p class="first">Type signature:</p>
<p>The signature of a type defines its identity, and also encodes some general
information about the type, such as its type parameters (if it’s parametric),
and its literal parameters. The literal parameters are used in types like
<code class="docutils literal"><span class="pre">VARCHAR(10)</span></code>.</p>
</li>
</ul>
</div>
</div>
<div class="bottomnav">
<p class="nav">
<span class="left">
« <a href="example-http.html">10.3. Example HTTP Connector</a>
</span>
<span class="right">
<a href="functions.html">10.5. Functions</a> »
</span>
</p>
</div>
<div class="footer" role="contentinfo">
</div>
</body>
</html>