Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2734] Create *Trafodion SQL Large Objects Guide* 1 #1229

Merged
merged 8 commits into from
Sep 27, 2017

Conversation

liuyu000
Copy link
Contributor

@liuyu000 liuyu000 commented Sep 10, 2017

Changes proposed in this pull request:

  1. Create Trafodion LOB Guide

@Traf-Jenkins
Copy link

Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2038/

@Traf-Jenkins
Copy link

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2040/

@Traf-Jenkins
Copy link

@liuyu000 liuyu000 changed the title [Trafodion-2734] Create *Trafodion LOB Guide* and Add 1st Chapter *Introduction* [Trafodion-2734] Create *Trafodion LOB Guide* Sep 11, 2017
@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2041/

@Traf-Jenkins
Copy link

@liuyu000
Copy link
Contributor Author

jenkins, retest

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2042/

@Traf-Jenkins
Copy link

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2043/

@Traf-Jenkins
Copy link

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2044/

@Traf-Jenkins
Copy link

Copy link
Contributor

@DaveBirdsall DaveBirdsall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only got about half way through. I hope to have more time tomorrow to review the rest.

<artifactId>sql-reference-manual</artifactId>
<version>${env.TRAFODION_VER}</version>
<packaging>pom</packaging>
<name>Trafodion SQL Reference Manual</name>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be different? Trafodion SQL Large Objects Guide perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reminding. :)
Yes I've changed it to Trafodion SQL Large Objects Guide.

<version>${env.TRAFODION_VER}</version>
<packaging>pom</packaging>
<name>Trafodion SQL Reference Manual</name>
<description>This manual describes reference information about the syntax of SQL statements,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description probably should be changed as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
Yes I've changed. :)


[[About_This_Document]]
= About This Document
This guide dwscribes how to use Large Object (LOB) datatypes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, "dwscribes". Also, might want to say "...how to use Large Object (LOB) datatypes in Trafodion SQL."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)

[cols="30%,70%",options="header"]
|===
|Chapter | Description
| <<Introduction,Introduction>> | Introduces LOB and covers following topics: +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "Introduces LOBs ..." is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)

|===
|Chapter | Description
| <<Introduction,Introduction>> | Introduces LOB and covers following topics: +
&#8226; 1.1 <<what is lob,What is LOB>> +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "what is a lob,What is a LOB" is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)


LOB (Large Object), a set of large object data types used to store large volumes of data, provides random and piece-wise access to the data.

Database support for LOB is not universal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section, are you trying to define the concept of "LOB" in general (that is, for any database), or just for Trafodion? Are you trying to define the notion of a LOB data type? Or a value that might be stored there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Just for Trafodion.
  2. Both. Define the notion first, and then the value (1.4 LOB Handle).


Stores unusually large amounts of string data in character set format. +

CLOB is ideal for storing and processing semi-structured data, such as large document or string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"... such as a large document or string" is better. Alternatively, "...such as large documents or strings"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)

[#lob storage]
== LOB Storage

The basic design idea is to allow a database row to have multiple LOB columns and a table to have multiple such rows. The design takes a combination approach of rows store and column store.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"row store" is better ("row" is being used as an adjective)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)


The basic design idea is to allow a database row to have multiple LOB columns and a table to have multiple such rows. The design takes a combination approach of rows store and column store.

When a SQL table with LOB column is created, there are several dependent objects that are created to hold metadata information on the LOB as well as the data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"with a LOB column" is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)


When a SQL table with LOB column is created, there are several dependent objects that are created to hold metadata information on the LOB as well as the data.

The LOB data itself is stored in HDFS while the Trafodion table contains a unique LOB handle for each row/column. The LOB handle provides the identifier that is used to query the LOB metadata tables to find the location of the LOB data files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"an HDFS file" is better. A question: Is each LOB value stored in a separate HDFS file? Or are several LOB values stored in one HDFS file? Also, "...a unique LOB handle for each row/column" might be better stated, "...a unique LOB handle for each LOB value".

Copy link
Contributor Author

@liuyu000 liuyu000 Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
I've corrected. :)

Answer from Sandhya:
Each lob column in any table will have it’s own unique lob data file. So any lob data belonging to that column will be stored in that HDFS file.

So if a table has 3 columns, you will see 3 lob data files with the first part of the name being the same and the column number will be appended to it.

For example, for a table with 2 lob columns:
Location: /user/trafodion/lobs
DataFile: LOBP_04474425229029907479_0001

Location: /user/trafodion/lobs
DataFile: LOBP_04474425229029907479_0002

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2045/

@Traf-Jenkins
Copy link

Copy link
Contributor

@DaveBirdsall DaveBirdsall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual is looking very good. There is so much detail to be documented. I had some questions, and I've made a few suggestions.

[#external structure]
=== External Structure

The following is an external structure that is stored in the row of a SQL table:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean, "The following is an example of an external structure..."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
Yes, I've corrected. :)

* LOB columns cannot be used as primary keys.
* LOB columns cannot be used in CREATE INDEX statements.
* LOB columns cannot be used in statistics update statements.
* The file that contains data to insert from or to extract to need to be on platform linux or HDFS files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "need to be" should be "needs to be" (because "needs" refers back to "The file" which is singular).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, "on platform linux or HDFS files." I think you mean, "on platform as a Linux or HDFS file."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.
Yes, I've corrected. :)

////

[#work with lob]
= Work with LOB
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider "Working with LOBs"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave.

Using gerund or verb (base) in title/headline is a style issue that should be followed consistently.

Gerundive (continuous) form is common in title and verb form seems more imperative, but given that

  1. the topic title plays a huge role in the search results
  2. Trafodion has many users of non-native English speakers

I think the verb form might be better as it more likely to match what people will search for, and uses the more familiar form of the verb.

Any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems ungrammatical to my ear. An imperative tense would clearly not be correct. We aren't telling the reader to "Work with LOBs!" (note the plural would be required, or alternatively the indefinite article, "Work with a LOB!"). Rather we are trying to describe how one works with LOBs. To me using the gerund seems most natural (in all cases, not just here); I would recommend changing the style to do that. Another possibility is to use the infinitive, e.g. "How to work with LOBs" (note again the plural). That might be more natural for English-as-a-second-language users whose native language lacks gerund-like inflections.

Copy link
Contributor Author

@liuyu000 liuyu000 Sep 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed explanation! :)
I've changed to "Working with LOBs".

== Syntax

```
CREATE TABLE table-name (lob-column-spec[, lob-column-spec]…)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax suggests that when you have lob columns in a table, you can't have other columns as well. Perhaps something like "CREATE TABLE table-name ( column_spec [, column_spec] ... [, primary_key_spec] )", then "column_spec is: lob-column-spec | other column spec"

Copy link
Contributor Author

@liuyu000 liuyu000 Sep 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave! :)

I'm planning to change it to:

CREATE TABLE table-name (column-spec[, column-spec]…)

column-spec is:
lob-column-spec |
other-column-spec

lob-column-spec is:
column-name {lob-data-type} [column-constraint]

other-column-spec is:
column-name {data-type} [column-constraint]

lob-data-type is:
BLOB | CLOB [({numeric literal} [unit])] [STORAGE 'storage literal']

...

Any comments?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave! :)
I've corrected.

* `_storage literal_`

+
Currently Trafodion only support `'EXTERNAL'` here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar. Should be "... supports ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave, I've corrected. :)

+
Trafodion engine will retrieve exactly the amount of requested data.
+
The user/application will be responsible for redriving the extract until EOD.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "EOD", I'd suggest "end of data" (we haven't defined this acronym anywhere, and it's not clear that we need to).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave, I've corrected. :)

+
If the target file exists, Trafodion will truncate and write to it.
+
If the target file does not exist, create a table, then write to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "If the target file does not exist, Trafodion will create it and write to it." (I assume Trafodion is creating the file here and not creating a table somewhere.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave, I've corrected. :)

+
If the target file exists, Trafodion will append to it.
+
If the target file does not exist, create a table, then write to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave, I've corrected. :)

[#extract lob data into a user specified buffer]
=== Extract Lob Data into a User Specified Buffer

Extract from a LOB column into a target user buffer of a specified size. Trafodion engine will retrieve exactly the amount of requested data. The user/application will be responsible for redriving the extract until EOD. Then the extracted buffer data can be written to files or another location as the application chooses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest "The Trafodion engine..."

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest also "end of data" instead of EOD.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dave, I've corrected. :)


Extract LOB data into a user specified buffer like a cursor until EOD is returned. For this method, the user specifies an input buffer and specifies the input length in an in/out variable.

For each execution of the extract, Trafodion will return SUCCESS, ERROR or EOD.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are SUCCESS, ERROR and EOD literals in some programming language (such as Java or C++)? Or is it a string that is returned by the Trafodion engine? Or something else? (The sqlci examples below don't mention SUCCESS, ERROR or EOD.) Seems like some additional explanation or examples are needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion from Sandhya:

Change
"For each execution of the extract, Trafodion will return SUCCESS, ERROR or EOD.
For the cases of SUCCESS or EOD, a length will also be returned to the user, so the user knows exactly how much data was actually extracted and returned. "

to

"Each successful execution of the extract will also return the length in the parameter specified by the caller, so the user knows how much data was actually extracted and returned. "

@liuyu000 liuyu000 changed the title [Trafodion-2734] Create *Trafodion LOB Guide* [TRAFODION-2734] Create *Trafodion LOB Guide* Sep 17, 2017
@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2058/

@Traf-Jenkins
Copy link

@Traf-Jenkins
Copy link

New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/2076/

@Traf-Jenkins
Copy link

Copy link
Contributor

@DaveBirdsall DaveBirdsall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 This looks great! Thanks for making this contribution. I think it is ready to merge.

@asfgit asfgit merged commit 0c32cb7 into apache:master Sep 27, 2017
@liuyu000 liuyu000 changed the title [TRAFODION-2734] Create *Trafodion LOB Guide* [TRAFODION-2734] Create *Trafodion SQL Large Objects Guide* 1 Sep 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
5 participants