Skip to content

Commit eea83c6

Browse files
authored
Merge pull request #1991 from schemacrawler/operations
Add JSON output format for operations
2 parents def2fb3 + 775521e commit eea83c6

File tree

37 files changed

+4214
-161
lines changed

37 files changed

+4214
-161
lines changed

schemacrawler-api/src/main/java/schemacrawler/crawl/MetadataResultSet.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import us.fatehi.utility.string.StringFormat;
4848

4949
/**
50-
* A wrapper around a JDBC resultset obtained from a database metadata call. This allows type-safe
50+
* A wrapper around a JDBC ResultSet obtained from a database metadata call. This allows type-safe
5151
* methods to obtain boolean, integer and string data, while abstracting away the quirks of the JDBC
5252
* metadata API.
5353
*/
@@ -63,6 +63,7 @@ public final class MetadataResultSet implements AutoCloseable {
6363
private Set<ResultsColumn> readColumns;
6464
private int rowCount;
6565
private boolean showLobs;
66+
private int maxRows;
6667

6768
public MetadataResultSet(
6869
final Query query, final Statement statement, final Map<String, InclusionRule> limitMap)
@@ -83,6 +84,7 @@ public MetadataResultSet(final ResultSet resultSet, final String description)
8384
resultsColumns = new ResultsCrawler(results).crawl();
8485
readColumns = new HashSet<>();
8586
showLobs = true;
87+
maxRows = Integer.MAX_VALUE;
8688
}
8789

8890
/**
@@ -358,6 +360,10 @@ public String getString(final String columnName) {
358360
* @throws SQLException On a database access error
359361
*/
360362
public boolean next() throws SQLException {
363+
if (rowCount == maxRows) {
364+
return false;
365+
}
366+
361367
readColumns = new HashSet<>();
362368

363369
final boolean next = results.next();
@@ -368,6 +374,10 @@ public boolean next() throws SQLException {
368374
return next;
369375
}
370376

377+
public void resetMaxRows() {
378+
maxRows = Integer.MAX_VALUE;
379+
}
380+
371381
public List<Object> row() throws SQLException {
372382
final List<Object> currentRow = new ArrayList<>();
373383
for (final ResultsColumn resultsColumn : resultsColumns) {
@@ -377,6 +387,13 @@ public List<Object> row() throws SQLException {
377387
return currentRow;
378388
}
379389

390+
public void setMaxRows(final int maxRows) {
391+
if (maxRows < 0) {
392+
return;
393+
}
394+
this.maxRows = maxRows;
395+
}
396+
380397
public void setShowLobs(final boolean showLobs) {
381398
this.showLobs = showLobs;
382399
}

schemacrawler-api/src/main/java/schemacrawler/crawl/RetrievalCounts.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ int get(final NamedObjectKey key) {
5959
private final Counts keyCount;
6060
private final Counts includedKeyCount;
6161

62-
RetrievalCounts(final String name) {
62+
public RetrievalCounts(final String name) {
6363
this.name = requireNotBlank(name, "No name provided");
6464
count = 0;
6565
includedCount = 0;
@@ -80,7 +80,7 @@ public String toString() {
8080
return String.format("%d/%d %s", includedCount, count, name);
8181
}
8282

83-
void count() {
83+
public void count() {
8484
count = count + 1;
8585
}
8686

@@ -93,7 +93,7 @@ void count(final NamedObjectKey key) {
9393
count = count + 1;
9494
}
9595

96-
void countIfIncluded(final boolean included) {
96+
public void countIfIncluded(final boolean included) {
9797
if (included) {
9898
includedCount = includedCount + 1;
9999
}
@@ -110,7 +110,7 @@ void countIfIncluded(final NamedObjectKey key, final boolean included) {
110110
}
111111
}
112112

113-
void countIncluded() {
113+
public void countIncluded() {
114114
includedCount = includedCount + 1;
115115
}
116116

@@ -123,7 +123,7 @@ void countIncluded(final NamedObjectKey key) {
123123
includedCount = includedCount + 1;
124124
}
125125

126-
void log() {
126+
public void log() {
127127
log(Level.INFO, count, includedCount, null);
128128
}
129129

schemacrawler-api/src/test/java/schemacrawler/test/utility/NeuteredExpressionsFilter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ final class NeuteredExpressionsFilter implements Function<String, String> {
2626
// SQL Server
2727
// -- primary key names
2828
Pattern.compile("PK__.{8}__[0-9A-F]{16}"),
29+
// DuckDB
30+
// -- JDBC driver configured values
31+
Pattern.compile(" value .*"),
2932
// Multi-threading
3033
Pattern.compile("main|pool-\\d+-thread-\\d+"),
3134
};

schemacrawler-commandline/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<artifactId>schemacrawler</artifactId>
2020
<version>${project.version}</version>
2121
</dependency>
22+
<dependency>
23+
<groupId>us.fatehi</groupId>
24+
<artifactId>schemacrawler-operations</artifactId>
25+
<version>${project.version}</version>
26+
</dependency>
2227

2328
<dependency>
2429
<groupId>us.fatehi</groupId>

schemacrawler-db2/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<artifactId>schemacrawler</artifactId>
2121
<version>${project.version}</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>us.fatehi</groupId>
25+
<artifactId>schemacrawler-operations</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
2328

2429
<dependency>
2530
<groupId>us.fatehi</groupId>

schemacrawler-dbtest/src/test/resources/testDuckDBWithConnection.LTE.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ System Information
44
========================================================================
55

66
generated by SchemaCrawler 16.26.3
7-
generated on 2025-07-12 18:36:32
7+
generated on 2025-07-25 21:42:46
88
database version DuckDB v1.3.2
99
driver version DuckDBJ 1.0
1010

@@ -320,7 +320,7 @@ uses local files true
320320

321321
JDBC Driver Information
322322
-=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-
323-
connection url jdbc:duckdb:C:\Users\RUNNER~1\AppData\Local\Temp\718193995532324056\sc.c5ccce54-0354-4126-ba74-dd5af4dcbf96.db
323+
connection url jdbc:duckdb:C:\Users\sualeh\AppData\Local\Temp\4637371908922847346\sc.548e1dad-6b5f-4b10-b1e4-feb9e6ff5576.db
324324
driver name DuckDBJ
325325
driver version 1.0
326326
driver class name org.duckdb.DuckDBDriver
@@ -778,7 +778,7 @@ max_expression_depth [driver property]
778778
max_memory [driver property]
779779
The maximum memory of the system (e.g. 1GB)
780780
not required
781-
value 12.5 GiB
781+
value 50.0 GiB
782782

783783
max_temp_directory_size [driver property]
784784
The maximum amount of data stored inside the 'temp_directory' (when set) (e.g. 1GB)
@@ -793,7 +793,7 @@ max_vacuum_tasks [driver property]
793793
memory_limit [driver property]
794794
The maximum memory of the system (e.g. 1GB)
795795
not required
796-
value 12.5 GiB
796+
value 50.0 GiB
797797

798798
merge_join_threshold [driver property]
799799
The number of rows we need on either table to choose a merge join
@@ -928,7 +928,7 @@ search_path [driver property]
928928
secret_directory [driver property]
929929
Set the directory to which persistent secrets are stored
930930
not required
931-
value C:\Users\runneradmin\.duckdb\stored_secrets
931+
value C:\Users\sualeh\.duckdb\stored_secrets
932932

933933
storage_compatibility_version [driver property]
934934
Serialize on checkpoint with compatibility for a given duckdb version
@@ -943,17 +943,17 @@ streaming_buffer_size [driver property]
943943
temp_directory [driver property]
944944
Set the directory to which to write temp files
945945
not required
946-
value c:\users\runner~1\appdata\local\temp\718193995532324056\sc.c5ccce54-0354-4126-ba74-dd5af4dcbf96.db.tmp
946+
value c:\users\sualeh\appdata\local\temp\4637371908922847346\sc.548e1dad-6b5f-4b10-b1e4-feb9e6ff5576.db.tmp
947947

948948
threads [driver property]
949949
The number of total threads used by the system.
950950
not required
951-
value 4
951+
value 12
952952

953953
TimeZone [driver property]
954954
The current time zone
955955
not required
956-
value Etc/UTC
956+
value America/New_York
957957

958958
user [driver property]
959959
The username to use. Ignored for legacy compatibility.
@@ -973,7 +973,7 @@ wal_autocheckpoint [driver property]
973973
worker_threads [driver property]
974974
The number of total threads used by the system.
975975
not required
976-
value 4
976+
value 12
977977

978978
zstd_min_string_length [driver property]
979979
The (average) length at which to enable ZSTD compression, defaults to 4096

schemacrawler-distrib/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<artifactId>schemacrawler-commandline</artifactId>
5959
<version>${project.version}</version>
6060
</dependency>
61+
<dependency>
62+
<groupId>us.fatehi</groupId>
63+
<artifactId>schemacrawler-operations</artifactId>
64+
<version>${project.version}</version>
65+
</dependency>
6166
<dependency>
6267
<groupId>us.fatehi</groupId>
6368
<artifactId>schemacrawler-scripting</artifactId>

schemacrawler-hsqldb/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<artifactId>schemacrawler</artifactId>
2121
<version>${project.version}</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>us.fatehi</groupId>
25+
<artifactId>schemacrawler-operations</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
2328

2429
<dependency>
2530
<groupId>us.fatehi</groupId>

schemacrawler-jdbc-drivers/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<relativePath>../schemacrawler-parent/pom.xml</relativePath>
1010
</parent>
1111
<artifactId>schemacrawler-jdbc-drivers</artifactId>
12-
<packaging>pom</packaging>
12+
<packaging>jar</packaging>
1313
<name>SchemaCrawler - JDBC Drivers Distribution</name>
1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -127,7 +127,8 @@
127127
<format>dir</format>
128128
</formats>
129129
<appendAssemblyId>false</appendAssemblyId>
130-
<finalName>_jdbc-drivers/lib</finalName>
130+
<finalName>lib</finalName>
131+
<outputDirectory>${project.build.directory}/_jdbc-drivers</outputDirectory>
131132
</configuration>
132133
<executions>
133134
<execution>

schemacrawler-jdbc-drivers/src/main/assembly/assembly.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<dependencySets>
1313
<dependencySet>
1414
<outputDirectory>.</outputDirectory>
15-
<useProjectArtifact>true</useProjectArtifact>
15+
<useProjectArtifact>false</useProjectArtifact>
1616
<unpack>false</unpack>
1717
<scope>runtime</scope>
1818
<excludes>

0 commit comments

Comments
 (0)