Description Objects from the Class Slots Extends Methods Author(s) See Also Examples
An object of this class represents a series of operations applied onto
an existing db.data.frame
object. These
operations are actually a SQL query, which one can choose to
materialize in the database using
as.db.data.frame
. lk
can fetch a part
of the result of executing the SQL query. Thus one does not need to
create a table for every step of the operations, and the data
transfered between R and the database is minimized.
Objects can be created by almost all functions/methods that can be
applied onto db.data.frame
except
content
, lk
and delete
.
db.Rview-class
is a sub-class of db.Rquery-class
, and it behaves just like "view" in the databases except that it exists only in R. Usually there is no difference to use db.Rview
or db.Rquery
. as.db.Rview
casts a db.Rquery
object into a db.Rview
object.
Usually it is NOT recommended to directly manipulate the internal slots of these objects.
.content
:Object of class "character"
. The SQL query that represents
the operations. The function content
can get this value.
.expr
:Object of class "character"
. An array of expression
strings for columns of the table that the SQL query can be
materialized into. It is not to used by the
normal users.
.source
:Object of class "character"
. A string, the table/view name
which this SQL query is originated. It is not to used by the
normal users.
.parent
:Object of class "character"
. A string. In the SQl query it
is the part after "from". It is not to used by the
normal users.
.conn.id
:Object of class "numeric"
, an integer. The ID number of the
database
connection where .source
resides. The functions
conn.id
and conn.id<-
can get and set
this value.
.col.name
:Object of class "character"
. An array of strings. The names
of columns of the table that the SQL query can be materialized
into. The
S4 method names,db.obj-method
gets this value.
.key
:Object of class "character"
. The name of the primary key
column name in .source
. Currently only one primary key
column is
supported. This value can be set during the creation of the object
when using the function db.data.frame
. The functions
key
and key<-
can be used to get and
set this value.
.col.data_type
:Object of class "character"
. The 1D array of column data
types of the table that the SQL query can be materialized
into. This is not supposed to be used by the normal user.
.col.udt_name
:Object of class "character"
. The 1D array of column udt
names of the table that the SQL query can be materialized
into. This is
not to used by normal users.
.where
:Object of class "character"
. The condition string used in
"where" inside the SQL query.
.is.factor
:Object of class "logical"
. An array of logical values which
indicate whether each column of the table that the SQL query can
be materialized
into is a factor. This
is not to be used by the normal users.
.factor.suffix
:Object of class "character"
. An array of strings for
every column. When creating dummy columns
for a factor column, we add a random string in the names of the
dummy columns to avoid naming conflicts. So a factor column's
.factor.suffix
is a random string, otherwise it is just an
empty string. This is not to be used by the normal users. It is
used only the MADlib wrapper functions that support categorical
variables.
.factor.ref
:The value of the factor reference level for the regressions. If it is NA
, then the regressions automatically select a reference level.
.sort
:Object of class "list"
. The list contains the information
used for "order by" in the SQL query.
by: A string. The column names that are used in "order by".
order: A string, "" or "desc"
str: A string, the full "order by ..." string.
.is.agg
:logical value, whether this object represents an aggregate operation.
.dist.by
:A string, the distribution policy for the original data table, which is used to construct this db.Rquery
object, when using Greenplum database or HAWQ. It can be character(0)
, which means the original data table is distributed randomly. Or it can be a string of column names separated by comma, which are the columns that are used in the "distributed by" when the original table was created.
Class "db.obj"
, directly.
All methods for db.data.frame
can be applied onto
this class.
Author: Predictive Analytics Team at Pivotal Inc.
Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io
db.data.frame
creates a db.data.frame
object.
as.db.data.frame
converts db.Rquery
object,
data.frame
, or a data file into a db.data.frame
object
and at the same time creates a new table in the database.
as.db.Rview
converts a db.Rquery
object to a db.Rview
object.
db.obj
is the superclass.
Class db.data.frame
is another sub-class of
db.obj
.
lk
display a part of the table
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 | ## Not run:
showClass("db.Rquery")
## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname)
delete("abalone", conn.id = cid)
x <- as.db.data.frame(abalone, "abalone", conn.id = cid)
## create several db.Rquery objects
y <- x[,1:2]
z <- x[x$rings > 10,]
dim(z) # get an error
lk(y)
lk(z)
## materialize a db.Rquery object
z <- as.db.data.frame(z, "abalone_rings_larger_10")
delete("abalone_rings_larger_10", conn.id = cid)
dim(z) # no error
db.disconnect(cid, verbose = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.