databricks-sqlalchemy 0.0.1b1__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +274 -0
- databricks/sqlalchemy/__init__.py +4 -2
- databricks/sqlalchemy/_ddl.py +100 -0
- databricks/sqlalchemy/_parse.py +385 -0
- databricks/sqlalchemy/_types.py +323 -0
- databricks/sqlalchemy/base.py +436 -0
- databricks/sqlalchemy/dependency_test/test_dependency.py +22 -0
- databricks/sqlalchemy/py.typed +0 -0
- databricks/sqlalchemy/pytest.ini +4 -0
- databricks/sqlalchemy/requirements.py +249 -0
- databricks/sqlalchemy/setup.cfg +4 -0
- databricks/sqlalchemy/test/_extra.py +70 -0
- databricks/sqlalchemy/test/_future.py +331 -0
- databricks/sqlalchemy/test/_regression.py +311 -0
- databricks/sqlalchemy/test/_unsupported.py +450 -0
- databricks/sqlalchemy/test/conftest.py +13 -0
- databricks/sqlalchemy/test/overrides/_componentreflectiontest.py +189 -0
- databricks/sqlalchemy/test/overrides/_ctetest.py +33 -0
- databricks/sqlalchemy/test/test_suite.py +13 -0
- databricks/sqlalchemy/test_local/__init__.py +5 -0
- databricks/sqlalchemy/test_local/conftest.py +44 -0
- databricks/sqlalchemy/test_local/e2e/MOCK_DATA.xlsx +0 -0
- databricks/sqlalchemy/test_local/e2e/test_basic.py +543 -0
- databricks/sqlalchemy/test_local/test_ddl.py +96 -0
- databricks/sqlalchemy/test_local/test_parsing.py +160 -0
- databricks/sqlalchemy/test_local/test_types.py +161 -0
- databricks_sqlalchemy-1.0.0.dist-info/LICENSE +201 -0
- databricks_sqlalchemy-1.0.0.dist-info/METADATA +225 -0
- databricks_sqlalchemy-1.0.0.dist-info/RECORD +31 -0
- {databricks_sqlalchemy-0.0.1b1.dist-info → databricks_sqlalchemy-1.0.0.dist-info}/WHEEL +1 -1
- databricks_sqlalchemy-1.0.0.dist-info/entry_points.txt +3 -0
- databricks/__init__.py +0 -7
- databricks_sqlalchemy-0.0.1b1.dist-info/METADATA +0 -19
- databricks_sqlalchemy-0.0.1b1.dist-info/RECORD +0 -5
@@ -0,0 +1,160 @@
|
|
1
|
+
import pytest
|
2
|
+
from databricks.sqlalchemy._parse import (
|
3
|
+
extract_identifiers_from_string,
|
4
|
+
extract_identifier_groups_from_string,
|
5
|
+
extract_three_level_identifier_from_constraint_string,
|
6
|
+
build_fk_dict,
|
7
|
+
build_pk_dict,
|
8
|
+
match_dte_rows_by_value,
|
9
|
+
get_comment_from_dte_output,
|
10
|
+
DatabricksSqlAlchemyParseException,
|
11
|
+
)
|
12
|
+
|
13
|
+
|
14
|
+
# These are outputs from DESCRIBE TABLE EXTENDED
|
15
|
+
@pytest.mark.parametrize(
|
16
|
+
"input, expected",
|
17
|
+
[
|
18
|
+
("PRIMARY KEY (`pk1`, `pk2`)", ["pk1", "pk2"]),
|
19
|
+
("PRIMARY KEY (`a`, `b`, `c`)", ["a", "b", "c"]),
|
20
|
+
("PRIMARY KEY (`name`, `id`, `attr`)", ["name", "id", "attr"]),
|
21
|
+
],
|
22
|
+
)
|
23
|
+
def test_extract_identifiers(input, expected):
|
24
|
+
assert (
|
25
|
+
extract_identifiers_from_string(input) == expected
|
26
|
+
), "Failed to extract identifiers from string"
|
27
|
+
|
28
|
+
|
29
|
+
@pytest.mark.parametrize(
|
30
|
+
"input, expected",
|
31
|
+
[
|
32
|
+
(
|
33
|
+
"FOREIGN KEY (`pname`, `pid`, `pattr`) REFERENCES `main`.`pysql_sqlalchemy`.`tb1` (`name`, `id`, `attr`)",
|
34
|
+
[
|
35
|
+
"(`pname`, `pid`, `pattr`)",
|
36
|
+
"(`name`, `id`, `attr`)",
|
37
|
+
],
|
38
|
+
)
|
39
|
+
],
|
40
|
+
)
|
41
|
+
def test_extract_identifer_batches(input, expected):
|
42
|
+
assert (
|
43
|
+
extract_identifier_groups_from_string(input) == expected
|
44
|
+
), "Failed to extract identifier groups from string"
|
45
|
+
|
46
|
+
|
47
|
+
def test_extract_3l_namespace_from_constraint_string():
|
48
|
+
input = "FOREIGN KEY (`parent_user_id`) REFERENCES `main`.`pysql_dialect_compliance`.`users` (`user_id`)"
|
49
|
+
expected = {
|
50
|
+
"catalog": "main",
|
51
|
+
"schema": "pysql_dialect_compliance",
|
52
|
+
"table": "users",
|
53
|
+
}
|
54
|
+
|
55
|
+
assert (
|
56
|
+
extract_three_level_identifier_from_constraint_string(input) == expected
|
57
|
+
), "Failed to extract 3L namespace from constraint string"
|
58
|
+
|
59
|
+
|
60
|
+
def test_extract_3l_namespace_from_bad_constraint_string():
|
61
|
+
input = "FOREIGN KEY (`parent_user_id`) REFERENCES `pysql_dialect_compliance`.`users` (`user_id`)"
|
62
|
+
|
63
|
+
with pytest.raises(DatabricksSqlAlchemyParseException):
|
64
|
+
extract_three_level_identifier_from_constraint_string(input)
|
65
|
+
|
66
|
+
|
67
|
+
@pytest.mark.parametrize("tschema", [None, "some_schema"])
|
68
|
+
def test_build_fk_dict(tschema):
|
69
|
+
fk_constraint_string = "FOREIGN KEY (`parent_user_id`) REFERENCES `main`.`some_schema`.`users` (`user_id`)"
|
70
|
+
|
71
|
+
result = build_fk_dict("some_fk_name", fk_constraint_string, schema_name=tschema)
|
72
|
+
|
73
|
+
assert result == {
|
74
|
+
"name": "some_fk_name",
|
75
|
+
"constrained_columns": ["parent_user_id"],
|
76
|
+
"referred_schema": tschema,
|
77
|
+
"referred_table": "users",
|
78
|
+
"referred_columns": ["user_id"],
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
def test_build_pk_dict():
|
83
|
+
pk_constraint_string = "PRIMARY KEY (`id`, `name`, `email_address`)"
|
84
|
+
pk_name = "pk1"
|
85
|
+
|
86
|
+
result = build_pk_dict(pk_name, pk_constraint_string)
|
87
|
+
|
88
|
+
assert result == {
|
89
|
+
"constrained_columns": ["id", "name", "email_address"],
|
90
|
+
"name": "pk1",
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
# This is a real example of the output from DESCRIBE TABLE EXTENDED as of 15 October 2023
|
95
|
+
RAW_SAMPLE_DTE_OUTPUT = [
|
96
|
+
["id", "int"],
|
97
|
+
["name", "string"],
|
98
|
+
["", ""],
|
99
|
+
["# Detailed Table Information", ""],
|
100
|
+
["Catalog", "main"],
|
101
|
+
["Database", "pysql_sqlalchemy"],
|
102
|
+
["Table", "exampleexampleexample"],
|
103
|
+
["Created Time", "Sun Oct 15 21:12:54 UTC 2023"],
|
104
|
+
["Last Access", "UNKNOWN"],
|
105
|
+
["Created By", "Spark "],
|
106
|
+
["Type", "MANAGED"],
|
107
|
+
["Location", "s3://us-west-2-****-/19a85dee-****/tables/ccb7***"],
|
108
|
+
["Provider", "delta"],
|
109
|
+
["Comment", "some comment"],
|
110
|
+
["Owner", "some.user@example.com"],
|
111
|
+
["Is_managed_location", "true"],
|
112
|
+
["Predictive Optimization", "ENABLE (inherited from CATALOG main)"],
|
113
|
+
[
|
114
|
+
"Table Properties",
|
115
|
+
"[delta.checkpoint.writeStatsAsJson=false,delta.checkpoint.writeStatsAsStruct=true,delta.minReaderVersion=1,delta.minWriterVersion=2]",
|
116
|
+
],
|
117
|
+
["", ""],
|
118
|
+
["# Constraints", ""],
|
119
|
+
["exampleexampleexample_pk", "PRIMARY KEY (`id`)"],
|
120
|
+
[
|
121
|
+
"exampleexampleexample_fk",
|
122
|
+
"FOREIGN KEY (`parent_user_id`) REFERENCES `main`.`pysql_dialect_compliance`.`users` (`user_id`)",
|
123
|
+
],
|
124
|
+
]
|
125
|
+
|
126
|
+
FMT_SAMPLE_DT_OUTPUT = [
|
127
|
+
{"col_name": i[0], "data_type": i[1]} for i in RAW_SAMPLE_DTE_OUTPUT
|
128
|
+
]
|
129
|
+
|
130
|
+
|
131
|
+
@pytest.mark.parametrize(
|
132
|
+
"match, output",
|
133
|
+
[
|
134
|
+
(
|
135
|
+
"PRIMARY KEY",
|
136
|
+
[
|
137
|
+
{
|
138
|
+
"col_name": "exampleexampleexample_pk",
|
139
|
+
"data_type": "PRIMARY KEY (`id`)",
|
140
|
+
}
|
141
|
+
],
|
142
|
+
),
|
143
|
+
(
|
144
|
+
"FOREIGN KEY",
|
145
|
+
[
|
146
|
+
{
|
147
|
+
"col_name": "exampleexampleexample_fk",
|
148
|
+
"data_type": "FOREIGN KEY (`parent_user_id`) REFERENCES `main`.`pysql_dialect_compliance`.`users` (`user_id`)",
|
149
|
+
}
|
150
|
+
],
|
151
|
+
),
|
152
|
+
],
|
153
|
+
)
|
154
|
+
def test_filter_dict_by_value(match, output):
|
155
|
+
result = match_dte_rows_by_value(FMT_SAMPLE_DT_OUTPUT, match)
|
156
|
+
assert result == output
|
157
|
+
|
158
|
+
|
159
|
+
def test_get_comment_from_dte_output():
|
160
|
+
assert get_comment_from_dte_output(FMT_SAMPLE_DT_OUTPUT) == "some comment"
|
@@ -0,0 +1,161 @@
|
|
1
|
+
import enum
|
2
|
+
|
3
|
+
import pytest
|
4
|
+
import sqlalchemy
|
5
|
+
|
6
|
+
from databricks.sqlalchemy.base import DatabricksDialect
|
7
|
+
from databricks.sqlalchemy._types import TINYINT, TIMESTAMP, TIMESTAMP_NTZ
|
8
|
+
|
9
|
+
|
10
|
+
class DatabricksDataType(enum.Enum):
|
11
|
+
"""https://docs.databricks.com/en/sql/language-manual/sql-ref-datatypes.html"""
|
12
|
+
|
13
|
+
BIGINT = enum.auto()
|
14
|
+
BINARY = enum.auto()
|
15
|
+
BOOLEAN = enum.auto()
|
16
|
+
DATE = enum.auto()
|
17
|
+
DECIMAL = enum.auto()
|
18
|
+
DOUBLE = enum.auto()
|
19
|
+
FLOAT = enum.auto()
|
20
|
+
INT = enum.auto()
|
21
|
+
INTERVAL = enum.auto()
|
22
|
+
VOID = enum.auto()
|
23
|
+
SMALLINT = enum.auto()
|
24
|
+
STRING = enum.auto()
|
25
|
+
TIMESTAMP = enum.auto()
|
26
|
+
TIMESTAMP_NTZ = enum.auto()
|
27
|
+
TINYINT = enum.auto()
|
28
|
+
ARRAY = enum.auto()
|
29
|
+
MAP = enum.auto()
|
30
|
+
STRUCT = enum.auto()
|
31
|
+
|
32
|
+
|
33
|
+
# Defines the way that SQLAlchemy CamelCase types are compiled into Databricks SQL types.
|
34
|
+
# Note: I wish I could define this within the TestCamelCaseTypesCompilation class, but pytest doesn't like that.
|
35
|
+
camel_case_type_map = {
|
36
|
+
sqlalchemy.types.BigInteger: DatabricksDataType.BIGINT,
|
37
|
+
sqlalchemy.types.LargeBinary: DatabricksDataType.BINARY,
|
38
|
+
sqlalchemy.types.Boolean: DatabricksDataType.BOOLEAN,
|
39
|
+
sqlalchemy.types.Date: DatabricksDataType.DATE,
|
40
|
+
sqlalchemy.types.DateTime: DatabricksDataType.TIMESTAMP_NTZ,
|
41
|
+
sqlalchemy.types.Double: DatabricksDataType.DOUBLE,
|
42
|
+
sqlalchemy.types.Enum: DatabricksDataType.STRING,
|
43
|
+
sqlalchemy.types.Float: DatabricksDataType.FLOAT,
|
44
|
+
sqlalchemy.types.Integer: DatabricksDataType.INT,
|
45
|
+
sqlalchemy.types.Interval: DatabricksDataType.TIMESTAMP_NTZ,
|
46
|
+
sqlalchemy.types.Numeric: DatabricksDataType.DECIMAL,
|
47
|
+
sqlalchemy.types.PickleType: DatabricksDataType.BINARY,
|
48
|
+
sqlalchemy.types.SmallInteger: DatabricksDataType.SMALLINT,
|
49
|
+
sqlalchemy.types.String: DatabricksDataType.STRING,
|
50
|
+
sqlalchemy.types.Text: DatabricksDataType.STRING,
|
51
|
+
sqlalchemy.types.Time: DatabricksDataType.STRING,
|
52
|
+
sqlalchemy.types.Unicode: DatabricksDataType.STRING,
|
53
|
+
sqlalchemy.types.UnicodeText: DatabricksDataType.STRING,
|
54
|
+
sqlalchemy.types.Uuid: DatabricksDataType.STRING,
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
def dict_as_tuple_list(d: dict):
|
59
|
+
"""Return a list of [(key, value), ...] from a dictionary."""
|
60
|
+
return [(key, value) for key, value in d.items()]
|
61
|
+
|
62
|
+
|
63
|
+
class CompilationTestBase:
|
64
|
+
dialect = DatabricksDialect()
|
65
|
+
|
66
|
+
def _assert_compiled_value(
|
67
|
+
self, type_: sqlalchemy.types.TypeEngine, expected: DatabricksDataType
|
68
|
+
):
|
69
|
+
"""Assert that when type_ is compiled for the databricks dialect, it renders the DatabricksDataType name.
|
70
|
+
|
71
|
+
This method initialises the type_ with no arguments.
|
72
|
+
"""
|
73
|
+
compiled_result = type_().compile(dialect=self.dialect) # type: ignore
|
74
|
+
assert compiled_result == expected.name
|
75
|
+
|
76
|
+
def _assert_compiled_value_explicit(
|
77
|
+
self, type_: sqlalchemy.types.TypeEngine, expected: str
|
78
|
+
):
|
79
|
+
"""Assert that when type_ is compiled for the databricks dialect, it renders the expected string.
|
80
|
+
|
81
|
+
This method expects an initialised type_ so that we can test how a TypeEngine created with arguments
|
82
|
+
is compiled.
|
83
|
+
"""
|
84
|
+
compiled_result = type_.compile(dialect=self.dialect)
|
85
|
+
assert compiled_result == expected
|
86
|
+
|
87
|
+
|
88
|
+
class TestCamelCaseTypesCompilation(CompilationTestBase):
|
89
|
+
"""Per the sqlalchemy documentation[^1] here, the camel case members of sqlalchemy.types are
|
90
|
+
are expected to work across all dialects. These tests verify that the types compile into valid
|
91
|
+
Databricks SQL type strings. For example, the sqlalchemy.types.Integer() should compile as "INT".
|
92
|
+
|
93
|
+
Truly custom types like STRUCT (notice the uppercase) are not expected to work across all dialects.
|
94
|
+
We test these separately.
|
95
|
+
|
96
|
+
Note that these tests have to do with type **name** compiliation. Which is separate from actually
|
97
|
+
mapping values between Python and Databricks.
|
98
|
+
|
99
|
+
Note: SchemaType and MatchType are not tested because it's not used in table definitions
|
100
|
+
|
101
|
+
[1]: https://docs.sqlalchemy.org/en/20/core/type_basics.html#generic-camelcase-types
|
102
|
+
"""
|
103
|
+
|
104
|
+
@pytest.mark.parametrize("type_, expected", dict_as_tuple_list(camel_case_type_map))
|
105
|
+
def test_bare_camel_case_types_compile(self, type_, expected):
|
106
|
+
self._assert_compiled_value(type_, expected)
|
107
|
+
|
108
|
+
def test_numeric_renders_as_decimal_with_precision(self):
|
109
|
+
self._assert_compiled_value_explicit(
|
110
|
+
sqlalchemy.types.Numeric(10), "DECIMAL(10)"
|
111
|
+
)
|
112
|
+
|
113
|
+
def test_numeric_renders_as_decimal_with_precision_and_scale(self):
|
114
|
+
self._assert_compiled_value_explicit(
|
115
|
+
sqlalchemy.types.Numeric(10, 2), "DECIMAL(10, 2)"
|
116
|
+
)
|
117
|
+
|
118
|
+
|
119
|
+
uppercase_type_map = {
|
120
|
+
sqlalchemy.types.ARRAY: DatabricksDataType.ARRAY,
|
121
|
+
sqlalchemy.types.BIGINT: DatabricksDataType.BIGINT,
|
122
|
+
sqlalchemy.types.BINARY: DatabricksDataType.BINARY,
|
123
|
+
sqlalchemy.types.BOOLEAN: DatabricksDataType.BOOLEAN,
|
124
|
+
sqlalchemy.types.DATE: DatabricksDataType.DATE,
|
125
|
+
sqlalchemy.types.DECIMAL: DatabricksDataType.DECIMAL,
|
126
|
+
sqlalchemy.types.DOUBLE: DatabricksDataType.DOUBLE,
|
127
|
+
sqlalchemy.types.FLOAT: DatabricksDataType.FLOAT,
|
128
|
+
sqlalchemy.types.INT: DatabricksDataType.INT,
|
129
|
+
sqlalchemy.types.SMALLINT: DatabricksDataType.SMALLINT,
|
130
|
+
sqlalchemy.types.TIMESTAMP: DatabricksDataType.TIMESTAMP,
|
131
|
+
TINYINT: DatabricksDataType.TINYINT,
|
132
|
+
TIMESTAMP: DatabricksDataType.TIMESTAMP,
|
133
|
+
TIMESTAMP_NTZ: DatabricksDataType.TIMESTAMP_NTZ,
|
134
|
+
}
|
135
|
+
|
136
|
+
|
137
|
+
class TestUppercaseTypesCompilation(CompilationTestBase):
|
138
|
+
"""Per the sqlalchemy documentation[^1], uppercase types are considered to be specific to some
|
139
|
+
database backends. These tests verify that the types compile into valid Databricks SQL type strings.
|
140
|
+
|
141
|
+
[1]: https://docs.sqlalchemy.org/en/20/core/type_basics.html#backend-specific-uppercase-datatypes
|
142
|
+
"""
|
143
|
+
|
144
|
+
@pytest.mark.parametrize("type_, expected", dict_as_tuple_list(uppercase_type_map))
|
145
|
+
def test_bare_uppercase_types_compile(self, type_, expected):
|
146
|
+
if isinstance(type_, type(sqlalchemy.types.ARRAY)):
|
147
|
+
# ARRAY cannot be initialised without passing an item definition so we test separately
|
148
|
+
# I preserve it in the uppercase_type_map for clarity
|
149
|
+
assert True
|
150
|
+
else:
|
151
|
+
self._assert_compiled_value(type_, expected)
|
152
|
+
|
153
|
+
def test_array_string_renders_as_array_of_string(self):
|
154
|
+
"""SQLAlchemy's ARRAY type requires an item definition. And their docs indicate that they've only tested
|
155
|
+
it with Postgres since that's the only first-class dialect with support for ARRAY.
|
156
|
+
|
157
|
+
https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.ARRAY
|
158
|
+
"""
|
159
|
+
self._assert_compiled_value_explicit(
|
160
|
+
sqlalchemy.types.ARRAY(sqlalchemy.types.String), "ARRAY<STRING>"
|
161
|
+
)
|
@@ -0,0 +1,201 @@
|
|
1
|
+
Apache License
|
2
|
+
Version 2.0, January 2004
|
3
|
+
http://www.apache.org/licenses/
|
4
|
+
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6
|
+
|
7
|
+
1. Definitions.
|
8
|
+
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
11
|
+
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13
|
+
the copyright owner that is granting the License.
|
14
|
+
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
16
|
+
other entities that control, are controlled by, or are under common
|
17
|
+
control with that entity. For the purposes of this definition,
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
19
|
+
direction or management of such entity, whether by contract or
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22
|
+
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24
|
+
exercising permissions granted by this License.
|
25
|
+
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
27
|
+
including but not limited to software source code, documentation
|
28
|
+
source, and configuration files.
|
29
|
+
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
31
|
+
transformation or translation of a Source form, including but
|
32
|
+
not limited to compiled object code, generated documentation,
|
33
|
+
and conversions to other media types.
|
34
|
+
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
36
|
+
Object form, made available under the License, as indicated by a
|
37
|
+
copyright notice that is included in or attached to the work
|
38
|
+
(an example is provided in the Appendix below).
|
39
|
+
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46
|
+
the Work and Derivative Works thereof.
|
47
|
+
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
49
|
+
the original version of the Work and any modifications or additions
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
61
|
+
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
64
|
+
subsequently incorporated within the Work.
|
65
|
+
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
72
|
+
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78
|
+
where such license applies only to those patent claims licensable
|
79
|
+
by such Contributor that are necessarily infringed by their
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
82
|
+
institute patent litigation against any entity (including a
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
85
|
+
or contributory patent infringement, then any patent licenses
|
86
|
+
granted to You under this License for that Work shall terminate
|
87
|
+
as of the date such litigation is filed.
|
88
|
+
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
91
|
+
modifications, and in Source or Object form, provided that You
|
92
|
+
meet the following conditions:
|
93
|
+
|
94
|
+
(a) You must give any other recipients of the Work or
|
95
|
+
Derivative Works a copy of this License; and
|
96
|
+
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
98
|
+
stating that You changed the files; and
|
99
|
+
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
102
|
+
attribution notices from the Source form of the Work,
|
103
|
+
excluding those notices that do not pertain to any part of
|
104
|
+
the Derivative Works; and
|
105
|
+
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
108
|
+
include a readable copy of the attribution notices contained
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
111
|
+
of the following places: within a NOTICE text file distributed
|
112
|
+
as part of the Derivative Works; within the Source form or
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
114
|
+
within a display generated by the Derivative Works, if and
|
115
|
+
wherever such third-party notices normally appear. The contents
|
116
|
+
of the NOTICE file are for informational purposes only and
|
117
|
+
do not modify the License. You may add Your own attribution
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
120
|
+
that such additional attribution notices cannot be construed
|
121
|
+
as modifying the License.
|
122
|
+
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
124
|
+
may provide additional or different license terms and conditions
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
128
|
+
the conditions stated in this License.
|
129
|
+
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
133
|
+
this License, without any additional terms or conditions.
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135
|
+
the terms of any separate license agreement you may have executed
|
136
|
+
with Licensor regarding such Contributions.
|
137
|
+
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
140
|
+
except as required for reasonable and customary use in describing the
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
142
|
+
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
152
|
+
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
158
|
+
incidental, or consequential damages of any character arising as a
|
159
|
+
result of this License or out of the use or inability to use the
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
162
|
+
other commercial damages or losses), even if such Contributor
|
163
|
+
has been advised of the possibility of such damages.
|
164
|
+
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168
|
+
or other liability obligations and/or rights consistent with this
|
169
|
+
License. However, in accepting such obligations, You may act only
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
174
|
+
of your accepting any such warranty or additional liability.
|
175
|
+
|
176
|
+
END OF TERMS AND CONDITIONS
|
177
|
+
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
179
|
+
|
180
|
+
To apply the Apache License to your work, attach the following
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182
|
+
replaced with your own identifying information. (Don't include
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
184
|
+
comment syntax for the file format. We also recommend that a
|
185
|
+
file or class name and description of purpose be included on the
|
186
|
+
same "printed page" as the copyright notice for easier
|
187
|
+
identification within third-party archives.
|
188
|
+
|
189
|
+
Copyright 2022 Databricks, Inc.
|
190
|
+
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
192
|
+
you may not use this file except in compliance with the License.
|
193
|
+
You may obtain a copy of the License at
|
194
|
+
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
196
|
+
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
200
|
+
See the License for the specific language governing permissions and
|
201
|
+
limitations under the License.
|