-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocs_stdlib.html
217 lines (185 loc) · 10.7 KB
/
docs_stdlib.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<html><head>
<title>DBToaster - DBToaster StdLib Reference</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="http://fortawesome.github.io/Font-Awesome/assets/font-awesome/css/font-awesome.css">
</head> <body>
<a name="pagetop"></a>
<div class="overallpage">
<div class="pagebody">
<div class="logobox">
<a href="index.html" ><img src="dbtoaster-logo.gif" width="214"
height="100" alt="DBToaster"/></a> </div>
<div class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">About <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="index.html" >Welcome to dbtoaster.org</a></li>
<li><a href="home_about.html" >Is DBToaster right for you?</a></li>
<li><a href="home_performance.html" >Performance</a></li>
<li><a href="home_features.html" >Features</a></li>
<li><a href="home_features.html#roadmap" ><small><i class="fa fa-caret-square-o-right"></i> Roadmap</small></a></li>
<li><a href="home_people.html" >The Team</a></li>
<li><a href="home_research.html" >For Researchers</a></li>
</ul>
</li>
<li class="dropdown">
<!--?php if(!isset($now_building_distro)) { ?-->
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Downloads <b class="caret"></b></a>
<!--?php } else { ?-->
<!--a href="#" class="dropdown-toggle" data-toggle="dropdown">License <b class="caret"></b></a-->
<!--?php } ?-->
<ul class="dropdown-menu">
<!--?php if(!isset($now_building_distro)) { ?-->
<li><a href="download.html" >Downloads</a></li>
<!--?php } ?-->
<li><a href="download.html#license" >License</a></li>
<li><a href="download.html#changelog" >Changelog</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="docs.html" >Installation</a></li>
<li><a href="docs_start.html" >Getting Started</a></li>
<li><a href="docs_architecture.html" >Architecture</a></li>
<li><a href="docs_compiler.html" >Command-Line Reference</a></li>
<li><a href="docs_compiler.html#options" ><small><i class="fa fa-caret-square-o-right"></i> Command-Line Options</small></a></li>
<li><a href="docs_compiler.html#languages" ><small><i class="fa fa-caret-square-o-right"></i> Supported Languages</small></a></li>
<li><a href="docs_compiler.html#opt_flags" ><small><i class="fa fa-caret-square-o-right"></i> Optimization Flags</small></a></li>
<li><a href="docs_sql.html" >DBToaster SQL Reference</a></li>
<li><a href="docs_stdlib.html" >DBToaster StdLib Reference</a></li>
<li><a href="docs_adaptors.html" >DBToaster Adaptors Reference</a></li>
<li><a href="docs_cpp.html" >C++ Code Generation</a></li>
<li><a href="docs_scala.html" >Scala Code Generation</a></li>
<li><a href="docs_java.html" >DBToaster in Java Programs</a></li>
<li><a href="docs_customadaptors.html" >Custom Adaptors</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Contact <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="home_contact.html#inquiries" >Inquiries</a></li>
<li><a href="home_contact.html#mailing" >Mailing List</a></li>
<li><a href="bugs.html" >Bug Reports</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="contentwrapper">
<div class="content">
<div class="doc_chain_link"> < <span class="doc_chain_link_prev"><a href="docs_sql.html" >DBToaster SQL Reference</a></span> | <span class="doc_chain_link_next"><a href="docs_adaptors.html" >DBToaster Adaptors Reference</a></span> > </div> <div class="titlebox">DBToaster StdLib Reference</div><p>DBToaster includes a standard library of functions that may used in SQL queries. Functions are called using a C-like syntax:
<div class="codeblock">SELECT listmin(A, B) FROM R;</div>
See <a href="docs_sql.html#select" >DBToaster SQL Reference</a> for information about calling functions.</p>
<hr/>
<h3>1. <span class="code">listmin, listmax</span></h3>Compute the minimum or maximum of a fixed-size list of values.
<div class="codeblock">listmin (val1, val2, [val3, [val4, [...]]])
listmax (val1, val2, [val3, [val4, [...]]])</div>
<h4>Inputs</h4>
<dl>
<dt class="code">val1, val2, ...: any</dt>
<dd>An arbitrary number of value expressions. All values in the list must be of the same type, or escalateable to the same type (e.g., Int -> Float), and must be comparable.</dd>
</dl>
<h4>Output</h4>
Returns the minimum or maximum element of <span class="code">val1, val2, ...</span>. The return type is the type of all of the elements of the list.
<h4>Notes</h4>
This library function is supported on the Interpreter, C++, and Scala runtimes.
<hr/>
<h3>2. <span class="code">date_part</span></h3>Extract the parts of a date. Identical to <span class="code">EXTRACT(datepart FROM date)</span>.
<div class="codeblock">date_part ('year', date)
date_part ('month', date)
date_part ('day', date)</div>
<h4>Inputs</h4>
<dl>
<dt class="code">datepart: string literal</dt>
<dd>One of the string literals 'year', 'month', or 'day'. Dictates which part of the date to extract. datepart is case-insensitive.</dd>
<dt class="code">date: date</dt>
<dd>The day to extract a component of.</dd>
</dl>
<h4>Output</h4>
Returns the requested year, month, or date part of a date, as an integer.
<h4>Notes</h4>
This library function is supported on the Interpreter and C++ runtimes.
<hr/>
<h3>3. <span class="code">regexp_match</span></h3>Perform regular expression matching.
<div class="codeblock">regexp_match (pattern, string)</div>
<h4>Inputs</h4>
<dl>
<dt class="code">pattern: string</dt>
<dd>A regular expression pattern (see Notes below).</dd>
<dt class="code">string: string</dt>
<dd>The string to match against.</dd>
</dl>
<h4>Output</h4>
Returns the integer 1 if the match succeeds, and the integer 0 otherwise.
<h4>Notes</h4>
<p>This library function is supported on the Interpreter and C++ runtimes.</p>
<p><b>Note:</b> Regular expressions are compiled and evaluated using each target runtime's native regular expression library. The Interpreter uses Ocaml's built in Str module. The C++ code generator uses <span class="code">regex(3)</span>.</p>
<hr/>
<h3>4. <span class="code">substring</span></h3>Extract a substring.
<div class="codeblock">substring (string, start, len)</div>
<h4>Inputs</h4>
<dl>
<dt class="code">string: string</dt>
<dd>The string to extract a substring from.</dd>
<dt class="code">start: int</dt>
<dd>The first character of string to return. 0 is the first character of the string.</dd>
<dt class="code">len: int</dt>
<dd>The length of the substring to return.</dd>
</dl>
<h4>Output</h4>
Returns the substring of string of length len, starting at index start.
<h4>Notes</h4>
<p>This library function is supported on the Interpreter and C++ runtimes.</p>
<hr/>
<h3>5. <span class="code">cast_int,cast_float,cast_string,cast_date</span></h3>Typecasting operations.
<div class="codeblock">cast_int(val)
cast_float(val)
cast_string(val)
cast_date(val)</div>
<h4>Inputs</h4>
<dl>
<dt class="code">val: any</dt>
<dd>The value to cast. The value's type must be one that is castable to the target type.</dd>
</dl>
<h4>Output</h4>
Returns the cast value of val as follows. If val is already of the target type, it is passed through unchanged.
<table border>
<tr><th>From</th><th>To</th><th>Notes</th></tr>
<tr><th>int</th><th>float</th><td> The floating point representation of the input.</td></tr>
<tr><th>int</th><th>string</th><td> The string representation of the input, as determined by the runtime's standard stringification functionality.</td></tr>
<tr><th>float</th><th>int</th><td> The integer representation of the input. Non-integer values will be truncated.</td></tr>
<tr><th>float</th><th>string</th><td> The string representation of the input, as determined by the runtime's standard stringification functionality.</td></tr>
<tr><th>date</th><th>string</th><td> The string representation of the input, in the SQL-standard <span class="code">YYYY-MM-DD</span> date format.</td></tr>
<tr><th>string</th><th>int</th><td> The input parsed as an integer, using the runtime's standard integer parsing functionality. <br/> (Ocaml: int_of_string, C++: atoi(3))</td></tr>
<tr><th>string</th><th>float</th><td> The input parsed as a float, using the runtime's standard integer parsing functionality. <br/> (Ocaml: float_of_string, C++: atof(3))</td></tr>
<tr><th>string</th><th>date</th><td> The input parsed as a date. The input string must be in SQL-standard <span class="code">YYYY-MM-DD</span> date format, or a runtime error will be generated.</td></tr>
</table>
<h4>Notes</h4>
<p>This library function is supported on the Interpreter and C++ runtimes.</p> <div class="doc_chain_link"> < <span class="doc_chain_link_prev"><a href="docs_sql.html" >DBToaster SQL Reference</a></span> | <span class="doc_chain_link_next"><a href="docs_adaptors.html" >DBToaster Adaptors Reference</a></span> > </div> </div><!-- /content -->
</div><!-- /contentwrapper -->
</div><!-- /pagebody -->
<div class="footer">
<hr/>
<p>Copyright (c) 2009-2014, The DBToaster Consortium. All rights reserved.</p>
</div>
</div><!-- /overallpage -->
<div id="pageEndElem" style="padding: 0 20px;"></div>
<script type="text/javascript" src="js/jquery-2.0.3.min.js"> </script>
<script type="text/javascript" src="js/bootstrap.min.js"> </script>
</body>
</html>