|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C) |
| 3 | +# 2019 MinIO, Inc. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +""" |
| 18 | +
|
| 19 | +This module creates the request for Select |
| 20 | +
|
| 21 | +:copyright: (c) 2019 by MinIO, Inc. |
| 22 | +:license: Apache 2.0, see LICENSE for more details. |
| 23 | +
|
| 24 | +""" |
| 25 | +from .helpers import (SQL) |
| 26 | + |
| 27 | + |
| 28 | +class CSVInput: |
| 29 | + """ |
| 30 | + CSVInput: Input Format as CSV. |
| 31 | + """ |
| 32 | + def __init__(self, FileHeaderInfo=None, RecordDelimiter="\n", |
| 33 | + FieldDelimiter=",", QuoteCharacter='"', |
| 34 | + QuoteEscapeCharacter='"', Comments="#", |
| 35 | + AllowQuotedRecordDelimiter=False): |
| 36 | + self.FileHeaderInfo = FileHeaderInfo |
| 37 | + self.RecordDelimiter = RecordDelimiter |
| 38 | + self.FieldDelimiter = FieldDelimiter |
| 39 | + self.QuoteCharacter = QuoteCharacter |
| 40 | + self.QuoteEscapeCharacter = QuoteEscapeCharacter |
| 41 | + self.Comments = Comments |
| 42 | + self.AllowQuotedRecordDelimiter = AllowQuotedRecordDelimiter |
| 43 | + |
| 44 | + |
| 45 | +class JSONInput: |
| 46 | + """ |
| 47 | + JSONInput: Input format as JSON. |
| 48 | + """ |
| 49 | + def __init__(self, Type=None): |
| 50 | + self.Type = Type |
| 51 | + |
| 52 | + |
| 53 | +class ParquetInput: |
| 54 | + """ |
| 55 | + ParquetInput: Input format as Parquet |
| 56 | + """ |
| 57 | + |
| 58 | + |
| 59 | +class InputSerialization: |
| 60 | + """ |
| 61 | + InputSerialization: nput Format. |
| 62 | + """ |
| 63 | + def __init__(self, compression_type="NONE", csv=None, json=None, par=None): |
| 64 | + self.compression_type = compression_type |
| 65 | + self.csv_input = csv |
| 66 | + self.json_input = json |
| 67 | + self.parquet_input = par |
| 68 | + |
| 69 | + |
| 70 | +class CSVOutput: |
| 71 | + """ |
| 72 | + CSVOutput: Output as CSV. |
| 73 | +
|
| 74 | + """ |
| 75 | + def __init__(self, QuoteFields="ASNEEDED", RecordDelimiter="\n", |
| 76 | + FieldDelimiter=",", QuoteCharacter='"', |
| 77 | + QuoteEscapeCharacter='"'): |
| 78 | + self.QuoteFields = QuoteFields |
| 79 | + self.RecordDelimiter = RecordDelimiter |
| 80 | + self.FieldDelimiter = FieldDelimiter |
| 81 | + self.QuoteCharacter = QuoteCharacter |
| 82 | + self.QuoteEscapeCharacter = QuoteEscapeCharacter |
| 83 | + |
| 84 | + |
| 85 | +class JsonOutput: |
| 86 | + """ |
| 87 | + JsonOutput- Output as JSON. |
| 88 | + """ |
| 89 | + def __init__(self, RecordDelimiter="\n"): |
| 90 | + self.RecordDelimiter = RecordDelimiter |
| 91 | + |
| 92 | + |
| 93 | +class OutputSerialization: |
| 94 | + """ |
| 95 | + OutputSerialization: Output Format. |
| 96 | + """ |
| 97 | + def __init__(self, csv=None, json=None): |
| 98 | + self.csv_output = csv |
| 99 | + self.json_output = json |
| 100 | + |
| 101 | + |
| 102 | +class RequestProgress: |
| 103 | + """ |
| 104 | + RequestProgress: Sends progress message. |
| 105 | + """ |
| 106 | + def __init__(self, enabled=False): |
| 107 | + self.enabled = enabled |
| 108 | + |
| 109 | + |
| 110 | +class SelectObjectOptions: |
| 111 | + """ |
| 112 | + SelectObjectOptions: Options for select object |
| 113 | + """ |
| 114 | + expression_type = SQL |
| 115 | + |
| 116 | + def __init__(self, expression, input_serialization, |
| 117 | + output_serialization, request_progress): |
| 118 | + self.expression = expression |
| 119 | + self.in_ser = input_serialization |
| 120 | + self.out_ser = output_serialization |
| 121 | + self.req_progress = request_progress |
0 commit comments